Category Archives: PHP

Php tutorials

Php – Do not rely on set_time_limit too much

By | June 5, 2013

Php set_time_limit Php has a function called set_time_limit which can be used to dynamically adjust the maximum execution time permitted to a script. It allows specifying the time in seconds and limits the script execution time to that many seconds. The set_time_limit function whenever called, effectively extends the script execution time by that many seconds…. Read More »

Php – Fix “Input is not proper UTF-8, indicate encoding” error when loading xml

By | March 26, 2013

When loading xml files in php through simplexml_load_string or domDocument class, sometimes an error like this might popup Warning: DOMDocument::loadXML(): Input is not proper UTF-8, indicate encoding ! OR Warning: simplexml_load_string(): Entity: line 93: parser error : Input is not proper UTF-8, indicate encoding ! The error occurs when the xml has some invalid characters… Read More »

Php – Fetch gzipped content over http with file_get_contents

By | March 24, 2013

The file_get_contents function is often used to quickly fetch a http url or resource. Usage is very simple and appears like this However the file_get_contents does not get the contents compressed. It requests the server to send everything in plain text format. Most websites are capable of serving compressed content, if they are asked to… Read More »

Parse the user agent with ua-parser in php – detect browser, os and device

By | March 22, 2013

In your web application you might need to parse the user’s user-agent string to find out the browser/OS/device being used. This is necessary specially when your webapp tries to adapt to the user’s platform in a better way. For example a different layout for mobile device or restricted features/graceful degradation on a non supporting browser…. Read More »