Today's Question:  What does your personal desk look like?        GIVE A SHOUT

40+ Techniques to enhance your php code

  Silver Moon        2012-04-10 13:06:55       4,162        0    

1. Do not use relative paths , instead define a ROOT path

Its quite common to see such lines :

1require_once('../../lib/some_class.php');

This approach has many drawbacks :

It first searches for directories specified in the include paths of php , then looks from the current directory.
So many directories are checked.

When a script is included by another script in a different directory , its base directory changes to that of the including script.

Another issue , is that when a script is being run from cron , it may not have its parent directory as the working directory.

So its a good idea to have absolute paths :

1define('ROOT' , '/var/www/project/');
2require_once(ROOT . '../../lib/some_class.php');
3 
4//rest of the code

Now this is an absolute path and will always stay constant. But we can improve this further. The directory /var/www/project can change , so do we change it everytime ? No instead we make it portable using magic constants like __FILE__ . Take a closer look :

1//suppose your script is /var/www/project/index.php
2//Then __FILE__ will always have that full path.
3 
4define('ROOT' , pathinfo(__FILE__, PATHINFO_DIRNAME));
5require_once(ROOT . '../../lib/some_class.php');
6 
7//rest of the code

So now even if you shift your project to a different directory , like moving it to an online server , the same code will run without any changes.

2. Dont use require , include , require_once or include_once

Your script could be including various files on top , like class libraries , files for utility and helper functions etc like this :

1require_once('lib/Database.php');
2require_once('lib/Mail.php');
3 
4require_once('helpers/utitlity_functions.php');

This is rather primitive. The code needs to be more flexible. Write up helper functions to include things more easily. Lets take an example :

1function load_class($class_name)
2{
3    //path to the class file
4    $path = ROOT . '/lib/' . $class_name . '.php');
5    require_once( $path );
6}
7 
8load_class('Database');
9load_class('Mail');

See any difference ? You must. It does not need any more explanation.
You can improve this further if you wish to like this :

1function load_class($class_name)
2{
3    //path to the class file
4    $path = ROOT . '/lib/' . $class_name . '.php');
5 
6    if(file_exists($path))
7    {
8        require_once( $path );
9    }
10}

There are a lot of things that can be done with this :

Search multiple directories for the same class file.
Change the directory containing class files easily , without breaking the code anywhere.
Use similar functions for loading files that contain helper functions , html content etc.

3. Maintain debugging environment in your application

During development we echo database queries , dump variables which are creating problems , and then once the problem is solved , we comment them or erase them. But its a good idea to let everything stay and help in the long run

On your development machine you can do this :

1define('ENVIRONMENT' , 'development');
2 
3if(! $db->query( $query )
4{
5    if(ENVIRONMENT == 'development')
6    {
7        echo "$query failed";
8    }
9    else
10    {
11        echo "Database error. Please contact administrator";
12    }
13}

And on the server you can do this :

1define('ENVIRONMENT' , 'production');
2 
3if(! $db->query( $query )
4{
5    if(ENVIRONMENT == 'development')
6    {
7        echo "$query failed";
8    }
9    else
10    {
11        echo "Database error. Please contact administrator";
12    }
13}

4. Propagate status messages via session

Status messages are those messages that are generated after doing a task.

1<?php
2if($wrong_username || $wrong_password)
3{
4    $msg = 'Invalid username or password';
5}
6?>
7<html>
8<body>
9 
10<?php echo $msg; ?>
11 
12<form>
13...
14</form>
15</body>
16</html>

Code like that is common. Using variables to show status messages has limitations. They cannot be send via redirects (unless you propagate them as GET variables to the next script , which is very silly). In large scripts there might be multiple messages etc.

Best way is to use session to propagate them (even if on same page). For this there has to be a session_start on every page.

1function set_flash($msg)
2{
3    $_SESSION['message'] = $msg;
4}
5 
6function get_flash()
7{
8    $msg = $_SESSION['message'];
9    unset($_SESSION['message']);
10    return $msg;
11}

and in your script :

1<?php
2if($wrong_username || $wrong_password)
3{
4    set_flash('Invalid username or password');
5}
6?>
7<html>
8<body>
9 
10Status is : <?php echo get_flash(); ?>
11<form>
12...
13</form>
14</body>
15</html>

5. Make your functions flexible

1function add_to_cart($item_id , $qty)
2{
3    $_SESSION['cart']['item_id'] = $qty;
4}
5 
6add_to_cart( 'IPHONE3' , 2 );

When adding a single item you use the above function. When adding multiple items , will you create another function ? NO. Just make the function flexible enough to take different kinds of parameters. Have a closer look :

1function add_to_cart($item_id , $qty)
2{
3    if(!is_array($item_id))
4    {
5        $_SESSION['cart']['item_id'] = $qty;
6    }
7 
8    else
9    {
10        foreach($item_id as $i_id => $qty)
11        {
12            $_SESSION['cart']['i_id'] = $qty;
13        }
14    }
15}
16 
17add_to_cart( 'IPHONE3' , 2 );
18add_to_cart( array('IPHONE3' => 2 , 'IPAD' => 5) );

So now the same function can accept different kinds of output. The above can be applied in lots of places to make your code more agile.

6. Omit the closing php tag if it is the last thing in a script

I wonder why this tip is omitted from so many blog posts on php tips.

1<?php
2 
3echo "Hello";
4 
5//Now dont close this tag

This will save you lots of problem. Lets take an example :

A class file super_class.php

1<?php
2class super_class
3{
4    function super_function()
5    {
6        //super code
7    }
8}
9?>
10//super extra character after the closing tag

Now index.php

1require_once('super_class.php');
2 
3//echo an image or pdf , or set the cookies or session data

And you will get Headers already send error. Why ? because the “super extra character” has been echoed , and all headers went along with that. Now you start debugging. You may have to waste many hours to find the super extra space.

Hence make it a habit to omit the closing tag :

1<?php
2class super_class
3{
4    function super_function()
5    {
6        //super code
7    }
8}
9 
10//No closing tag

Thats better.

7. Collect all output at one place , and output at one shot to the browser

This is called output buffering. Lets say you have been echoing content from different functions like this :

1function print_header()
2{
3    echo "<div id='header'>Site Log and Login links</div>";
4}
5 
6function print_footer()
7{
8    echo "<div id='footer'>Site was made by me</div>";
9}
10 
11print_header();
12for($i = 0 ; $i < 100; $i++)
13{
14    echo "I is : $i <br />';
15}
16print_footer();

Instead of doing like that , first collect all output in one place. You can either store it inside variables in the functions or use ob_start and ob_end_clean. So now it should look like

1function print_header()
2{
3    $o = "<div id='header'>Site Log and Login links</div>";
4    return $o;
5}
6 
7function print_footer()
8{
9    $o = "<div id='footer'>Site was made by me</div>";
10    return $o;
11}
12 
13echo print_header();
14for($i = 0 ; $i < 100; $i++)
15{
16    echo "I is : $i <br />';
17}
18echo print_footer();

So why should you do output buffering :

  • You can change the output just before sending it to browser if you need to. Think about doing some str_replaces , or may be preg_replaces or may be adding some extra html at the end like profiler/debugger output
  • Its a bad idea to send output to browser and do php processing at the same time. Have you ever seen a website where there is a Fatal error in the sidebar or in a box in the middle of the screen. You know why that happens ? Because processing and output are being mixed.

8. Send correct mime types via header when outputting non-html content

Lets echo some xml.

1$xml = '<?xml version="1.0" encoding="utf-8" standalone="yes"?>';
2$xml = "<response>
3  <code>0</code>
4</response>";
5 
6//Send xml data
7echo $xml;

Works fine. But it needs some improvement.

1$xml = '<?xml version="1.0" encoding="utf-8" standalone="yes"?>';
2$xml = "<response>
3  <code>0</code>
4</response>";
5 
6//Send xml data
7header("content-type: text/xml");
8echo $xml;

Note that header line. That line tells the browser that the content is xml content. So the browser can handle it correctly. Many javascript libraries also rely on header information.

Similarly for javascript , css , jpg image , png image :

Javascript

1header("content-type: application/x-javascript");
2echo "var a = 10";

CSS

1header("content-type: text/css");
2echo "#div id { background:#000; }";

9. Set the correct character encoding for a mysql connection

Ever faced a problem that unicode/utf-8 characters are stored in mysql table correctly , phpmyadmin also shows them correct , but when you fetch them and echo on your page they do not show up correctly. The secret is mysql connection collation.

1//Attempt to connect to database
2$c = mysqli_connect($this->host , $this->username, $this->password);
3 
4//Check connection validity
5if (!$c
6{
7    die ("Could not connect to the database host: <br />". mysqli_connect_error());
8}
9 
10//Set the character set of the connection
11if(!mysqli_set_charset ( $c , 'UTF8' ))
12{
13    die('mysqli_set_charset() failed');
14}

Once you connect to the database , its a good idea to set the connections characterset. This is a must when you are working with multiple languages in your application.

10. Use htmlentities with the correct characterset option

Prior to php 5.4 the default character encoding used is ISO-8859-1 which cannot display characters like À â etc.

1$value = htmlentities($this->value , ENT_QUOTES , CHARSET);

Php 5.4 onwards the default encoding will be UTF-8 which will solve most problems , but still better be aware about it if your application is multilingual.

11. Do not gzip output in your application , make apache do that

Thinking of using ob_gzhandler ? No dont do that. It doesnt make sense. Php is supposed to write your application. Dont worry about how to optimise data transfer between server and browser inside Php.

Use apache mod_gzip/mod_deflate to compress content via the .htaccess file.

12. Use json_encode when echoing javascript code from php

There are times when some javascript code is generated dynamically from php.

1$images = array(
2 'myself.png' , 'friends.png' , 'colleagues.png'
3);
4 
5$js_code = '';
6 
7foreach($images as $image)
8{
9$js_code .= "'$image' ,";
10}
11 
12$js_code = 'var images = [' . $js_code . ']; ';
13 
14echo $js_code;
15 
16//Output is var images = ['myself.png' ,'friends.png' ,'colleagues.png' ,];

Be smart. use json_encode :

1$images = array(
2 'myself.png' , 'friends.png' , 'colleagues.png'
3);
4 
5$js_code = 'var images = ' . json_encode($images);
6 
7echo $js_code;
8 
9//Output is : var images = ["myself.png","friends.png","colleagues.png"]

Isn’t that neat ?

13. Check if directory is writable before writing any files

Before writing or saving any file , make sure you check that the directory is writable or not , and flash an error message if it is not. This will save you a lot of “debugging” time. When you are working on a linux , permissions have to be dealt with and there would be many many permission issues when directories would not be writable , files would not be readable and so on.

Make sure that your application is as intelligent as possible and reports the most important information in the shortest time.

1$contents = "All the content";
2$file_path = "/var/www/project/content.txt";
3 
4file_put_contents($file_path , $contents);

That is totally correct. But has some indirect problems. The file_put_contents may fail for a number of reasons :

  • Parent directory does not exist
  • Directory exists , but is not writable
  • File locked for writing ?

So its better to make everything clear before writing out to a file.

1$contents = "All the content";
2$dir = '/var/www/project';
3$file_path = $dir . "/content.txt";
4 
5if(is_writable($dir))
6{
7    file_put_contents($file_path , $contents);
8}
9else
10{
11    die("Directory $dir is not writable, or does not exist. Please check");
12}

By doing this you get the accurate information that where is a file write failing and why

14. Change permission of files that your application creates

When working in linux environment , permission handling can waste a lot of your time. Hence whenever your php application creates some files do a chmod over them to ensure they are “accessible” outside. Otherwise for example the files may be created by “php” user and you are working as a different user and the system wont let you access or open the file , and then you have to struggle to get root privileges , change the permissions of the file and so on.

1// Read and write for owner, read for everybody else
2chmod("/somedir/somefile", 0644);
3 
4// Everything for owner, read and execute for others
5chmod("/somedir/somefile", 0755);

15. Don’t check submit button value to check form submission

1if($_POST['submit'] == 'Save')
2{
3    //Save the things
4}

The above is mostly correct , except when your application is multi-lingual. Then the ‘Save’ can be many different things. How would you compare then. So do not rely on the value of submit button. Instead use this :

1if( $_SERVER['REQUEST_METHOD'] == 'POST' and isset($_POST['submit']) )
2{
3    //Save the things
4}

Now you are free from the value the submit button

16. Use static variables in function where they always have same value

1//Delay for some time
2function delay()
3{
4    $sync_delay = get_option('sync_delay');
5 
6    echo "<br />Delaying for $sync_delay seconds...";
7    sleep($sync_delay);
8    echo "Done <br />";
9}

Instead use static variables as :

1//Delay for some time
2function delay()
3{
4    static $sync_delay = null;
5 
6    if($sync_delay == null)
7    {
8    $sync_delay = get_option('sync_delay');
9    }
10 
11    echo "<br />Delaying for $sync_delay seconds...";
12    sleep($sync_delay);
13    echo "Done <br />";
14}

17. Don’t use the $_SESSION variable directly

Some simple examples are :

1$_SESSION['username'] = $username;
2$username = $_SESSION['username'];

But this has a problem. If you are running multiple applications on the same domain , the session variables my conflict. 2 different applications may set the same key name in the session variable. Take for example , a frontend portal , and the backend management application , on the same domain.

Hence use application specific keys with wrapper functions :

1define('APP_ID' , 'abc_corp_ecommerce');
2 
3//Function to get a session variable
4function session_get($key)
5{
6    $k = APP_ID . '.' . $key;
7 
8    if(isset($_SESSION[$k]))
9    {
10        return $_SESSION[$k];
11    }
12 
13    return false;
14}
15 
16//Function set the session variable
17function session_set($key , $value)
18{
19    $k = APP_ID . '.' . $key;
20    $_SESSION[$k] = $value;
21 
22    return true;
23}

18. Wrap utility helper functions into a class

So you have a lot of utility functions in a file like :

1function utility_a()
2{
3    //This function does a utility thing like string processing
4}
5 
6function utility_b()
7{
8    //This function does nother utility thing like database processing
9}
10 
11function utility_c()
12{
13    //This function is ...
14}

And you use the function throughout your application freely. You may want to wrap them into a class as static functions :

1class Utility
2{
3    public static function utility_a()
4    {
5 
6    }
7 
8    public static function utility_b()
9    {
10 
11    }
12 
13    public static function utility_c()
14    {
15 
16    }
17}
18 
19//and call them as
20 
21$a = Utility::utility_a();
22$b = Utility::utility_b();

One clear benefit you get here is if php has inbuilt functions with similar names , then names will not conflict.
Another perspective , though little advanced is that you can maintain multiple versions of the same class in the same application without any conflict. Its basically encapsulation , nothing else.

19. Bunch of silly tips

  • Use echo instead of print
  • Use str_replace instead of preg_replace , unless you need it absolutely
  • Do not use short tags
  • Use single quotes instead of double quotes for simple strings
  • Always remember to do an exit after a header redirect
  • Never put a function call in a for loop control line.
  • isset is faster than strlen
  • Format your code correctly and consistently
  • Do not drop the brackets of loops or if-else blocks.
    Do not code like this :
    1if($a == true) $a_count++;

    Its absolutely a WASTE.

    Write

    1if($a == true)
    2{
    3    $a_count++;
    4}

    Dont try to make your code shorter by eating up syntax. Rather make your logic shorter.

  • Use a proper text editor which has code highlighting. Code highlighting helps to create lesser errors.

20. Process arrays quickly with array_map

Lets say you want to trim all elements of an array. Newbies do it like this :

1foreach($arr as $c => $v)
2{
3    $arr[$c] = trim($v);
4}

But it can more cleaner with array_map :

1$arr = array_map('trim' , $arr);

This will apply trim on all elements of the array $arr. Another similar function is array_walk. Check out the
documentation on these to know more.

21. Validate data with php filters

Have you been using to regex to validate values like email , ip address etc. Yes everybody had been doing that. Now lets
try something different, called filters.

The php filter extension provides simple way to validate or check values as being a valid ‘something’.

22. Force type checking

1$amount = intval( $_GET['amount'] );
2$rate = (int) $_GET['rate'];

Its a good habit.

23. Write Php errors to file using set_error_handler()

set_error_handler() can be used to set a custom error handler. A good idea would be write some important errors in a file for logging purpose

24. Handle large arrays carefully

Large arrays or strings , if a variable is holding something very large in size then handle with care. Common mistake is to create a copy and then run out of memory and get a Fatal Error of Memory size exceeded :

1$db_records_in_array_format; //This is a big array holding 1000 rows from a table each having 20 columns , every row is atleast 100 bytes , so total 1000 * 20 * 100 = 2MB
2 
3$cc = $db_records_in_array_format; //2MB more
4 
5some_function($cc); //Another 2MB ?

The above thing is common when importing a csv file or exporting table to a csv file

Doing things like above can crashs scripts quite often due to memory limits. For small sized variables its not a problem , but must be avoided when handling large arrays.

Consider passing them by reference , or storing them in a class variable :

1$a = get_large_array();
2pass_to_function(&$a);

by doing this the same variable (and not its copy) will be available to the function. Check documentation

1class A
2{
3    function first()
4    {
5        $this->a = get_large_array();
6        $this->pass_to_function();
7    }
8 
9    function pass_to_function()
10    {
11        //process $this->a
12    }
13}

unset them as soon as possible , so that memory is freed and rest of the script can relax.

25. Use a single database connection, throughout the script

Make sure that you use a single connection to your database throughout your script. Open a connection right in the beginning and use it till the end , and close it at the end. Do not open connections inside functions like this :

1function add_to_cart()
2{
3    $db = new Database();
4    $db->query("INSERT INTO cart .....");
5}
6 
7function empty_cart()
8{
9    $db = new Database();
10    $db->query("DELETE FROM cart .....");
11}

Having multiple connections is a bad idea and moreover they slow down the execution since every connection takes time to create and uses more memory.

Use the singleton pattern for special cases like database connection.

26. Avoid direct SQL query , abstract it

Writing too many queries like this :

1$query = "INSERT INTO users(name , email , address , phone) VALUES('$name' , '$email' , '$address' , '$phone')";
2$db->query($query); //call to mysqli_query()

Not a robust approach. It has drawbacks :

  • escape the values everytime manually
  • Verify if the query is correct
  • Wrong queries may go undetected for a long time (unless if else checking done everytime)
  • Difficult to maintain large queries like that

Therefore write up for yourself simple functions like these :

1function insert_record($table_name , $data)
2{
3    foreach($data as $key => $value)
4    {
5    //mysqli_real_escape_string
6        $data[$key] = $db->mres($value);
7    }
8 
9    $fields = implode(',' , array_keys($data));
10    $values = "'" . implode("','" , array_values($data)) . "'";
11 
12    //Final query
13    $query = "INSERT INTO {$table}($fields) VALUES($values)";
14 
15    return $db->query($query);
16}
17 
18$data = array('name' => $name , 'email' => $email  , 'address' => $address , 'phone' => $phone);
19 
20insert_record('users' , $data);

Saw that ? it makes things simpler and scalable. The function insert_record takes care of escaping data correctly.
Biggest advantage here is that since the data is being prepared as a php array , any syntax mistake is caught instantly.

This function should be a part of your database class , which you can call like this $db->insert_record.
Check this article on how to make your own database class for easy database handling.

Similar functions should be written for update , select , delete as well. Try doing it.

27. Cache database generated content to static files

For all pages that are generated by fetching content from the database , they should be cached. It means that once generated , save a copy in a temporary directory. Next time the same page is requested , then fetch it from the cache directory , dont query the database again.

Benefits :

  • Save php processing to generate the page , hence faster execution
  • Lesser database queries means lesser load on mysql database

28. Store sessions in database

File based sessions have many limitation. Applications using file based sessions cannot scale to multiple servers , since files are stoed on a single server. But database can be access from multiple servers hence the the problem is solved there.

Storing session in database makes many other things easier like :

  • Restrict concurrent logins from same username. Same username cannot log in from 2 different places at same time.
  • Check online status of users more accurately.

29. Avoid using globals

  • Use defines/constants
  • Get value using a function
  • Use Class and access via $this

30. Use base url in head tag

Heard of this ? It looks like this :

1<head>
3</head>
4<body>
5<img src="happy.jpg" />
6</body>
7</html>

This base tag is a very useful thing. Suppose you are organising your webpages in sub directories , but all of them need to contain a consistent navigation menu.

www.domain.com/store/home.php
www.domain.com/store/products/ipad.php

In your home.php you can write

1<a href="home.php">Home</a>
2<a href="products/ipad.php">Ipad</a>

But in your ipad.php you have to write

1<a href="../home.php">Home</a>
2<a href="ipad.php">Ipad</a>

Because directories are different. For this multiple versions of the navigation html code has to be maintained , which is a bad idea. So use base tag

1<head>
3</head>
4<body>
5<a href="home.php">Home</a>
6<a href="products/ipad.php">Ipad</a>
7</body>
8</html>

Now this particular code will work the same way in the home directory as well as the product directory. The base href value is used to form the full url for home.php and products/ipad.php

Thats it.

31. Never set error_reporting to 0

Just switch off the not so relevant errors. E_FATAL errors are important to know. If you dont find out , someone else will report the error , making your work easy.

1ini_set('display_errors', 1);
2error_reporting(~E_WARNING & ~E_NOTICE & ~E_STRICT);

32. Be aware of platform architecture

The length of integers is different on 32 and 64 bit architectures. So functions like strtotime behave differently.

On a 64 bit machine you can see such output.

1$ php -a
2Interactive shell
3 
4php > echo strtotime("0000-00-00 00:00:00");
5-62170005200
6php > echo strtotime('1000-01-30');
7-30607739600
8php > echo strtotime('2100-01-30');
94104930600

But on a 32 bit machine all of them would give bool(false). Check here for more.

33. Dont rely on set_time_limit too much

If you are limiting the maximum time , a script can run by doing this :

1set_time_limit(30);
2 
3//Rest of the code

it may not always work. Any execution that happens outside the script via system calls/os functions like socket operations , database operations etc. will not be under control of set_time_limit.

So if a database operation takes lot of time or “hangs” then the script will not stop. So make better strategies according to the situation

34. Make a portable function for executing shell commands

system , exec , passthru , shell_exec are the 4 functions that are available to execute system commands. Each has a slightly different behaviour. But the problem is that when you are working on shared hosting environments some of the functions are selectively disabled. Most newbie programmers tend to first find out which function is enabled and then use it.

A better solution :

1/**
2    Method to execute a command in the terminal
3    Uses :
4 
5    1. system
6    2. passthru
7    3. exec
8    4. shell_exec
9 
10*/
11function terminal($command)
12{
13    //system
14    if(function_exists('system'))
15    {
16        ob_start();
17        system($command , $return_var);
18        $output = ob_get_contents();
19        ob_end_clean();
20    }
21    //passthru
22    else if(function_exists('passthru'))
23    {
24        ob_start();
25        passthru($command , $return_var);
26        $output = ob_get_contents();
27        ob_end_clean();
28    }
29 
30    //exec
31    else if(function_exists('exec'))
32    {
33        exec($command , $output , $return_var);
34        $output = implode("\n" , $output);
35    }
36 
37    //shell_exec
38    else if(function_exists('shell_exec'))
39    {
40        $output = shell_exec($command) ;
41    }
42 
43    else
44    {
45        $output = 'Command execution not possible on this system';
46        $return_var = 1;
47    }
48 
49    return array('output' => $output , 'status' => $return_var);
50}
51 
52terminal('ls');

The above function will execute the shell command using whichever function is available , keeping your code consistent.

35. Use a profiler like xdebug if you need to

If you are writing large scale applications in php that do a lot of processing , then speed is an important factor. Use profilers to check how your code is performing in terms of speed. Check out xdebug and webgrid.

36. Use plenty of external libraries

Here are few :

  • mPDF – Generate pdf documents, by converting html to pdf beautifully.
  • PHPExcel – Read and write Excel files
  • PhpMailer – Send html emails with attachments easily
  • pChart – Generate graphs in php

Use open source libraries for complex tasks like generating pdf , ms-excel files , charts etc.

37. Have a look at phpbench for some micro-optimisation stats

phpbench has some benchmarks for various syntax variations that can create significant difference. Check it.

38. Use an MVC framework

Its time to start using an MVC framework like codeigniter. MVC framework dont really make you write object oriented code. They just make you separate PHP code from HTML code.

  • Clean separation of php and html code. Good for team work , when designers and coders are working together.
  • Functions and functionalities are organised in classes making maintenance easy.
  • Inbuilt libraries for lots of things , you may not need to code again
  • Is a must when writing big applications
  • Lots of tips, techniques, hacks are already implemented in the framework

39. Read the comments on the php documentation website

They contain expert advice and useful code snippets. Check them out.

40. Go to the IRC channel to ask

Have a question , got stuck somewhere in your code ?
Go to the irc channel #php and ask. Its the best place to get answers and instantly.

41. Read open source code

Read other open source applications. You get to learn a lot.

42. Develop on Linux

Do php development on a Linux (or may be Mac ?) machine. This will help in many ways like :

Source : http://www.binarytides.com/blog/35-techniques-to-enhance-your-php-code/

PHP  EFFICIENCY  QUIRK  TRICK  TECHNIQUES 

Share on Facebook  Share on Twitter  Share on Weibo  Share on Reddit 

  RELATED


  0 COMMENT


No comment for this article.