Developers are magicians and they know all the magic tricks and cool little functions. So, Here are some more hidden magic tricks for all the PHP Devs out there... 1. Omit the closing php tag if it is the last thing in a script2. Use PHP echo like a FunctionExample:$text = 'test'; echo 'Text: ', $text, ''; 3. Check if directory is writable before writing any filesExample:if(is_writable($dir)) { file_put_contents($file_path , $contents); } else { die('Directory not writable'); }4. Use str_replace instead of preg_replace , unless you need it absolutely5. Use single quotes instead of double quotes for simple strings as they are the first to be executed.6. isset is faster than strlen7. Process/Iterate the arrays faster using 'array_map' rather than foreach8. Use a single database connection throughout the script.9.  Set 'display_errors=On' in php.ini on development  and  'display_errors=Off' in on production10.  Use Plenty of external libraries like PHPExcel, PHPMailer, pChart etc. - Study24x7
Social learning Network
study24x7

Default error msg

Login

New to Study24x7 ? Join Now
Already have an account? Login
58 followers study24x7 11 Apr 2020 08:02 PM study24x7 study24x7

Developers are magicians and they know all the magic tricks and cool little functions. So, Here are some more hidden magic tricks for all the PHP Devs out there... 

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

2. Use PHP echo like a Function<...

See more

study24x7
Write a comment
Related Questions
500+   more Questions to answer
Most Related Articles