This is second lesson in PHP Lessons series. The previous lesson of PHP Lessons series was about Installation of Apache service for PHP and in this
lesson we will learn how to create and execute a php file.
Creating a PHP file is very easy. The only thing you need to create a PHP file is a source code editor like Notepad, Notepad++ or Dream Viewer etc. I prefer using Notepad++ for coding and you can download it here if you want. To create a PHP file open your code editor and click on the file tab to show the drop down.
Now click on Save As from the drop down. Enter the name of your file in the input box File name and select the file type as PHP hypertext preprocessor file from the drop down. Click on the save button to save the PHP file.
To execute a PHP file in a web browser first of all start the Apache service and copy your php file to the htdocs directory of your XAMPP server. If your PHP file is in the htdocs directory and the file name is test.php then paste localhost/test.php in your web browser to execute the file. Write any random text in your php file and execute it in your web browser to check the output.
How to create a PHP file?
Creating a PHP file is very easy. The only thing you need to create a PHP file is a source code editor like Notepad, Notepad++ or Dream Viewer etc. I prefer using Notepad++ for coding and you can download it here if you want. To create a PHP file open your code editor and click on the file tab to show the drop down.
Now click on Save As from the drop down. Enter the name of your file in the input box File name and select the file type as PHP hypertext preprocessor file from the drop down. Click on the save button to save the PHP file.
How to execute a PHP file?
To execute a PHP file in a web browser first of all start the Apache service and copy your php file to the htdocs directory of your XAMPP server. If your PHP file is in the htdocs directory and the file name is test.php then paste localhost/test.php in your web browser to execute the file. Write any random text in your php file and execute it in your web browser to check the output.
No comments:
Post a Comment