PHP Development India – Best Language for Web Development

September 28, 2011 1 comment

Hi All,

In today’s advanced technological world, the popularity of the internet has been increasing and we see millions of websites running on the internet to fulfill the requirement of user and the figure keeps increasing each day. Therefore, the merchants are getting cut-throat competition on the internet. Strong representation of a website is thus necessary for its online success. Hence, merchants have been diverted to web development industry to build the strong online presence.

There are many options available for web development like php, asp.net, java, wordpress, etc., from them php becomes a first choice for company websites. Because PHP is an open source server side scripting language, which allows effective web development at affordable rates. PHP support multiple platforms and databases such as Linux kernel, MS Windows, MySQL, MS Access, SQL server & Oracle. It also offers an array of other features which can be used to make a website flexible and user-friendly.

Benefits of PHP Development:

  • Create a dynamic website that has a professional look
  • Its support various OS (operating system) like Windows, Linux and Unix
  • The coding is easily understandable
  • Web development at very affordable rates
  • Increase your ROI (Return of Investment)

Many countries provide php development services, from them India has taken first place in this field because Indian php developers offer excellent designing and development services and take new challenges with open arms and most important thing, you get your application at one-quarter of cost at your current rate.

 

 

Advertisements

Submit Form Using Ajax (Post)

September 24, 2011 1 comment

Post.html

<script type="text/javascript" language="javascript">// <![CDATA[
var h_request = false;
function makePOSTRequest(url, parameters) {
h_request = false;

<!--more-->

if (window.XMLHttpRequest) //MOZILLA
{
h_request = new XMLHttpRequest();
if (h_request.overrideMimeType)
{
h_request.overrideMimeType('text/html');
}
}
else if (window.ActiveXObject) { // IE
try {
h_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
h_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!h_request) {
alert('Cannot create XMLHTTP instance');
return false;
}

h_request.onreadystatechange = alertContents;
h_request.open('POST', url, true);
h_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
h_request.setRequestHeader("Content-length", parameters.length);
h_request.setRequestHeader("Connection", "close");
h_request.send(parameters);
}

function alertContents() {
if (h_request.readyState == 4) {
if (h_request.status == 200) {
result = h_request.responseText;
document.getElementById('myspan').innerHTML = result;
} else {
alert('There was a problem with the request.');
}
}
}

function get(obj) {
var poststr = "mytextarea1=" + encodeURI( document.getElementById("mytextarea1").value ) +
"&mytextarea2=" + encodeURI( document.getElementById("mytextarea2").value );
makePOSTRequest('post.php', poststr);
}

// ]]></script>

<form action="javascript:get(document.getElementById('form1'));" name="form1" id="form1">
<textarea id="mytextarea1">testing data
1
2
3
</textarea>
<textarea id="mytextarea2">testing data 2
4
5
6</textarea>
<br>
<input type="button" name="button" value="Submit"
onclick="javascript:get(this.parentNode);">

</form>

<br><br>
Server-Response:<br>
<hr>
<span name="myspan" id="myspan"></span>
<hr>

Post.php

<?
print_r($_POST);
?>
Categories: ajax, Androide developer, CakePHP, CakePHP Developer India, freelance developer, Freelance PHP Developer, Freelance PHP Programmer, Freelance Programmer India, freelance web, freelance web designer, Freelance web developer, get a freelancer, Hire Dedicated Programmer, Hire Dedicated Programmer India, Hire PHP Developer India, Hire PHP Professional, Hire PHP Professional India, Hire PHP Programmer India, Hire Web developer, Hire Web Developer India, india web development, Indian Freelancer, iOS, ipad, iphone developer, JavaScript, joomla, joomla developer india, jquery, mysql, oscommerce Customization, oscommerce developer, php, PHP Freelancer, PHP Freelancer India, php freelancing india, php freelancing india mumbai, PHP programmer, PHP Programmer India, Php programming, PHP Web Development, php web programmer, web designer india, Web Developement Company USA, web developer, web developer ahemdabad india, web developer india, Web development India, Word Press Reserch, wordpress, Wordpress Blog Developer, Wordpress Customization Services, wordpress freelance developer, wordpress freelance programmer, wordpress freelancer, Wordpress Freelancer India, Wordpress Programmer, Wordpress Shopping Cart, Wordpress theme customization, wordpress theme integration, x cart development india Tags: , , , , , , , , , , , , , , , , , , , ,

Optimizing PHP Through Habits

September 23, 2011 Leave a comment

What has been a long interest of mine in writing simple, maintainable and secure (a.k.a. Good[tm]) code, has forked off the offspring of optimization.

There are nummerous discussions in the blogosphere about whether to use echo versus print, iffor() is faster than while(), etc. and though the gains are usually very small, I desided to add my thoughts to the debate.

I found an article on optimization through coding habits in Ilia Alshanetsky’s zend performance slides and decided to test some of the claims. My test machine is my MacBook Pro 1.83GHz w. 2GB RAM, MacOS X 10.4.9, Apache 1.3 and PHP 5.2 (with Xdebug 2.0). I also have lots of applications running.

  • Peter Bowyer claims that require_once() is 3-4 times slower than require(). Ilia also says they are bad. My testing reveals the exact opposite with an empty include file. Callingrequire_once() 10000 times in a for() loop with an empty file is 4x faster.
  • Ilia advises against using magic functions like __autoload() and __get(), but the advantage of __autoload() in particular is obvious in any large project and is used by many phpframeworks. My primitive testing, however, shows inverse results. With a simply autoload requiring a class and 10000 loops of new Foo() versus require_once('foo.php'); new Foo() shows that __autoload() is ~3.7 times faster. I saw no difference between real methods and __get(), although the logic inside __get() will add some overhead.
  • If a class method can be static, declare it static. Speed improvement is by a factor of 4. I get a 50% speed increase (614ms vs. 414ms with 100000 iterations).
  • Avoid function calls within for() loop control blocks. In for( $i=0; $i<count($x); $i++ )the count($x) is called at every iteration.
  • Always, always quote array keys. $row['id'] is way faster than $row[id]. Ilia says 700%, I say about 200%.
  • Avoid regex if possible. Use ctype_digit($foo); rather than preg_match("![0-9]+!", $foo);.
  • Get rid of ‘harmless’ error messages – they take time to generate and output. The error supression operator @ is slow, so avoid when possible. With error_reporting set to E_ALL | E_STRICT on my machine, doing echo $rows[id] 10000 times instead of echo $rows['id]takes 38 times longer.

     

    UPDATE: To summarize, this slow code runs in 500ms (although this time will vary a great deal depending on your error_reporting level):

     

     

     

     

    $rows = array_fill(0, 10000, array('id'=>0));
    require_once('foo.php');
    for( $i=0; $i < count($rows); $i++) {
        foo::notdeclaredstatic();
    
        $rows[$i][id] = 0;
    }
    
    
    
    
    By using the techniques above, it can be made to complete in 68ms:
    
    $rows = array_fill(0, 10000, array('id'=>0));
    function __autoload($classname) { require_once( 'foo.php'); }
    $size = count($rows);
    for( $i=0; $i < $size; $i++) {
        foo::declaredstatic();
    
        $rows[$i]['id'] = 0;
    }
    
    
    10000 iterations is a lot for one request to a page. Using the techniques, the code became roughly 7 times faster.
    
    I am not out to prove Ilia wrong - he knows PHP better than most - and 
    for all I know, they could have optimized those very functions in PHP 5.2. I am, however, 
    interested in seeing what can be done to optimize PHP performance simply by doing things differently,
    by tweaking one's coding style. It would appear that there are improvements, albeit small, to achieve 
    from minimal effort. Plus I was surprised by the discrepancies I found compared to Ilia's recommendations.
    
    

     

Timezones in MySQL and PHP

September 22, 2011 Leave a comment

Timezones in web applications are often dealt with the same way as character sets. Either incorrectly or ignored. The case of unicode is improving slowly as developers discover the need for international language support.
The problem with not handling timezones correctly is not apparent in the usual case of the webserver and the database server being in the same timezone. A lot of PHP code passes the task of timestamps on to MySQL, e.g. by calling NOW() on inserting or updating records. It is nessesary to know in what timezone the timestamps are stored to process them correctly.

Often a specific timezone is assumed for displaying date and time. This could very well be incorrect for a large number of visitors. If the database server is in yet another timezone, things begin to get out of sync.

MySQL’s handling of timezones is – obviously – separate from that of PHP. Along with the fact that the MySQL timezone can only be changed by users with SUPER privileges, this means that MySQL cannot be relied on for creation of timestamps in correct timezone. In other words, the usual call toNOW() is not an option.

PHP 5.1 introduced the date_default_timezone_set() method for setting the timezone PHP will use for functions like date() (or alternatively the date.timezone php.ini directive). This allows for a flexible and consistent way of creating timestamps in the correct timezone form within PHP. One user in London might start a thread while a response comes from New York. To handle this consistently and make sure both users see local time and the correct timespan between the posts, use date_default_timezone_set() to create the timestamps from PHP in a fixed timezone like GMT.

Time for an example to illustrate the practical use of this. I created a simple class Timer for dealing with these operations. The methods will be called statically as there is no need to instantiate the class.


class Timer 
{   
    static function DatetimeInGMT() {
        return date("Y-m-d H:i:s", time()-date("Z",time()));
    }

    static function GMTDatetimeToLocal($datetime) {
        $time = strtotime($datetime);
        return date("Y-m-d H:i:s", $time+date("Z",$time));
    }
}


Timer::DatetimeInGMT() produces a timestamp in GMT. I use it instead of MySQL’s NOW()because it calculates the time relative to the timezone set in PHP rather than that of MySQL.

When reading the timestamp back in to PHP, another function call is needed to convert it back to whatever timezone PHP is in at that time (it might be a different user viewing with another timezone setting). That’s the job of Timer::GMTDatetimeToLocal($datetime).

These two very simple functions and a correct setting of PHP’s timezone will ensure that dates are stored in a consistent way and displayed correctly.

 

 

CakePHP Auth Component For Dummies Tutorial

September 21, 2011 3 comments

First off, I would like to say much thanks to Gwoo for finally helping me to understand this thing.

So I know what you’re thinking; I’m probably the last person to finally figure out the CakePHP’s Auth Component. For the past few months, I’ve been using obAuthbecause that’s the only authentication I could get to work with CakePHP. I think that I was just making it more difficult than it should have been.

My main resource for learning the Auth Component has been Chris’s tutorial, but even then I still needed help. Also, I’m the type that doesn’t really learn much without code.

Note that I’m running off of the CaekPHP 1.2 beta.

Getting Started

Now you can modify this however you like, but I’m starting out with the basics. You’re going to need the following:

  • A user database with fields usernamepassword. Of course they don’t need to be named that way, but defaults are fun.
  • A User Model with Controller and Views – This can be baked from CakePHP
  • A login view for the user.
  • And a base app_controller.php. That’s it.

The Setup – app_controller and users_controller

So here’s the minimum in app_controller:

 

 

 

var $components = array('Auth');
 
function beforeFilter(){
    $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
    $this->Auth->loginRedirect = array('controller' => 'pages', 'action' => 'display', 'home');
    $this->Auth->allow('display');
    $this->Auth->authorize = 'controller';
}
function isAuthorized() {
    return true;
}


You can always visit the API for a better understanding of what’s going on, but right now we’re just trying to get stuff working.

After that there’s the users_controller.php. This you can get straight out of CakePHP’s baking. You do need a small modification:

 

function login()
{
}
 
function logout(){
    $this->Session->setFlash('Logout');
    $this->redirect($this->Auth->logout());
}

Brief Explanation

Honestly, it’s magic; automagic to be precise. If you want to know how it works, you can read up in the API. But what I will do, is give you some of the magic words.

$this->Auth->authorize = ‘controller’

There are different types of authorization action (ugh – ACL stuff), CRUD (basically locks up all the editing stuff), and controller (gives you some need control). Hey, sorry I don’t know too much of what it does, just what I need.

$this->Auth->loginAction = array(‘controller’ => ‘users’, ‘action’ => ‘login’)

This tells yo what the login page is. It also controls where the user is redirected to if he’s not authorized to view a page.

$this->Auth->loginRedirect = array(‘controller’ => ‘pages’, ‘display’ => ‘home’)

Self explanatory: default action to redirect the user to when logged in if they go straight to the login page. If, however, they tried to access a restricted page then this will be ignored and when they login they’ll be redirected to where they wanted to go to.

$this->Auth->allow(array(‘display’))

This is one of the magic functions. By default, adding the authentication component locks down all actions, except the login and logout. This is your way of telling the component let me in to the ‘display’ action for every controller. You at least want to see the homepage right?

You can also add to this in the beforeFilter() of each controller you you need (don’t forget theparent::beforeFilter() to make sure the Auth stuff is still called). Likewise there’s a $this->Auth->deny(), which does the reverse. One small tip: you can also use allow(array(‘*’)) to allow everything.

User Controller

For right now, the login() action can be left as is. The Auth Component handles all that foot work beautifully. You just need to make sure you call $this->Auth->logout() in your logout() action. It has the added benefit of returning the Auth’s logoutRedirect, so $this->redirect($this->Auth->logout() works great.

Hire PHPBB Developer for Robust Web Forum Development

September 21, 2011 Leave a comment

In the online business, businessmen suppose to be using various web techniques to promote the business on the web. The more interaction with the related entities can open the more avenues for the business and one of the best modes of interaction and sharing information on the web is forums.Internet forums with business websites can do amazing business promotional work. Developing web forum involves a fair programming work that is complex for novice businessmen. One of the popular & unique PHPBB (PHP Bulletin Board) systems for developing robust internet forums to business websites is available in the web development. PHPBB softwareis based on PHP programming language. However, web forums can be developed using various other computer programming languages such as Perl, Java and ASP. Internet forum development for websites is complex and costly process. Businessman can hire PHPBB developer / programmerfor making it cost-effective & customize to use with business website.

Internet forums are efficient tool to use with business as they incredibly great source to reach and converse with people. Designing, developing and hosting of internet forums is costly process and small businessman or online business company suppose to seek affordable alternative. As PHP is an open source scripting language and hire dedicated PHPBB developer is the best option that can save precious money. He can specially build or performPHPBB development, customize it and host cost – effectively. Anyone in the online business can hire PHPBB Developer from PHP Web Development Company. The concept of hiring dedicated developer is popular in the present times, which is very helpful in technical terms as well as in the matter of affordability. Customized designing, development and hosting all three can be derived from one professional. Moreover, a hiredPHPBB Developer can provide the benefits or implement the features of all updated versions such as PHPBB2 & PHPBB3 into business.

Categories: .htaccess, CakePHP, CakePHP Developer India, freelance developer, Freelance PHP Developer, Freelance PHP Programmer, Freelance Programmer India, freelance web, freelance web designer, Hire Dedicated Programmer, Hire Dedicated Programmer India, Hire PHP Developer India, Hire PHP Professional, Hire PHP Professional India, Hire PHP Programmer India, Hire Web developer, Hire Web Developer India, india web development, Indian Freelancer, iphone 4, iphone application developer, iphone developer, JavaScript, joomla customization india, Joomla Developer, joomla developer india, jquery, mysql, php, PHP Developer, PHP Developer India, PHP Development, PHP Freelance, PHP Freelancer, PHP Freelancer India, php freelancing india, php freelancing india mumbai, PHP programmer, Php programming, web designer india, Web Developement Company USA, web developer, web developer ahemdabad india, web developer india, wordpress, Wordpress Blog Developer, Wordpress Customization Services, wordpress freelancer, Wordpress Freelancer India, Wordpress Programmer, Wordpress Shopping Cart, Wordpress theme customization, wordpress theme integration, x cart development india, x-cart Tags: , , , , , , , , , , , , , , , , , , ,

Hire X-Cart Developer for Cost-Effective & Secure eCommerce Solutions

September 21, 2011 Leave a comment

Proper implementation of the shopping cart software is very vital. A high quality shopping cart software with a wide range of features is useless if not implemented appropriately. X-cart shopping cart software is popular open source product with various features that are required for high quality eCommerce website. For the best possible use of X-cart technology in eCommerce website development, developer / programmer suppose to be proficient in his programming practices. An excellent technology and proficient developer can decide the whole design of online business. TheeCommerce website ought to be fast & error-free functioning to ultimate users. The administrator or website owner always look for good management and control on the website and supposed to be flexible for any modifications. Integration of new modules and features must be easy in the future in any high quality eCommerce website. All this could be done by hiring X-Cart developer. Hire X-Cart Developer is one of the potential options available for the robust eCommerce website development.

 

Special dedicated developer on rent is comparatively cost effective for setting up eCommerce business or developing eCommerce website. The job of eCommerce website development is costly if someone wants to start at small level such as selling products & services from home. The small businessmen can hire X-Cart developer from web development service providers for integrating the X-Cart shopping cart software in business websites (eCommerce websites). The companies and big businessmen also prefer the concept of hiring dedicated developers from any reliable web development company. For instance, the trends of offshore outsourcing in the modern online business are common and hire X-Cart programmer is very popular practice for developing cost – effective eCommerce websites. Moreover, small businessmen can have the facilities of customization in the eCommerce web development by hiring dedicated X-Cart developer.

 

This slideshow requires JavaScript.

For the last many years retail business on the web is very regular practice by the small & big retailers/ merchants. They always seek cost effectiveeCommerce shopping cart solutions and there are hundreds of shopping cart software are available to utilize in the eCommerce websites. Among the popular shopping carts, X-Cart is the well-known name and eCommerce developers also admire practicing eCommerce website development with them. A proficient X-Cart developer on hire is the best resource for providing comprehensive eCommerce solution. A large number of online businessmenhire X-Cart developers for making their existing online business more productive by replacing the old shopping cart software. X-Cart amazing eCommerce technology offers high level security features. Different entities such as whole sellers, retailers, distributors, eCommerce solution providers and various internet companies like to hire X-Cart Developer. 

%d bloggers like this: