php.ini : Most commonly used php directives

Below are the most commonly used php directives. You have to change php.ini file in order to configure php settings. This just means changing these directive’s option and value. 1) short_open_tag = Off Allow the many servers don’t support short tags. 2) max_execution_time = 30 Maximum execution time of each script, in seconds 3) error_reporting … Read more

How to find php version and php.ini file location path?

We can view the php settings by creating a php file in our web root with the following code: <?php phpinfo(); ?> Let the name of the file be phpinfo.php The file location will be: /var/www/phpinfo.php (For Linux) C://xampp/htdocs/phpinfo.php (For Windows with Xampp) C://wamp/www/phpinfo.php (For Windows with Wamp) Open http://localhost/phpinfo.php in your browser in your … Read more

PHP : Read Write XML with DOMDocument

In this article, I will be showing you how to create and read xml document with php’s DOMDocument. The DOM extension allows you to operate on XML documents through the DOM API with PHP 5. Below is the code to create XML file. I have named the output file ‘example.xml’. For better understanding, I have … Read more

PHP Javascript : Playing with multi-dimensional array

I had to work on multi-dimensional array with javascript and php. I had a multi-dimensional array in php. I had to load it into javascript array and then populate the html selection list. The challenge for me was to create multi-dimensional array in javascript and populate selection list with for loop in javascript. Here is … Read more

PHP : Read Write XML with SimpleXML

In this article, I will be showing you how to create and read xml document with php’s SimpleXML extension. The SimpleXML extension provides a very simple and easily usable toolset to convert XML to an object that can be processed with normal property selectors and array iterators. Below is the code to create XML file. … Read more

Multiple file upload using jQuery and PHP

This tutorial shows how easy it is to upload multiple files using jQuery and PHP. I have used jQuery MultiFile Plugin for this purpose. The input type file should have name in list format like “pic[]” and the class name of the input should be “multi”. <input type="file" name="pic[]" class="multi" /> Below is the complete … Read more

PHP: How to get working website path and directory name?

This tutorial shows site name, working directory name, etc. with the help of $_SERVER variable. Let us suppose, that our website is: http://wwww.example.com/test/admin/index.php 1) Get name of the website echo $_SERVER['SERVER_NAME']; OR, echo $_SERVER['HTTP_HOST']; This will print: www.example.com 2) Get the path of the page you are working on echo $_SERVER['PHP_SELF']; This will print: /test/admin/index.php … Read more

PHP: How to get (view) html source code of a website

Here is the PHP code to fetch the html source code of any website specified. fopen function is used to open the website URL. stream_get_contents is used to read the opened URL. The fetched code is displayed inside a textarea. $domain = 'http://example.com'; $handle = fopen($domain, 'r'); $content = stream_get_contents($handle); /** // alternative to stream_get_contents … Read more