Start PHP
Start php programming language and run program using xampp, wamp and lamp Local Server. If you have finished to installation of Local Server(like xampp, wamp, lamp) then first create a project folder under the local server an run project in a browser( like Google Chrome, Mozilla Firefox, Internet Explorer). Enter in url localhost/project name. If your project name will my_project then enter localhost/my_project.
Make a project directory :
If the local server is WAMP, then make a directory in wamp\www\Project_name\index.php
- wamp
- www
- project_name
- index.php file
- project_name
- www
Example:
<?php echo "Hello PHP"; ?>
Output: Hello PHP
If the local server is LAMP, then make a directory in var\www\html\Project_name\index.php
- var
- www
- html
- project_name
- index.php file
- project_name
- html
- www
Example:
<?php $variable="Welcome to PHP code"; echo $variable; ?>
Output: Welcome to PHP
If the local server is XAMPP then make a directory in c:/program files\xampp\htdocs\Project_name\index.php :
Create a project folder in the Local Server after install Xampp or wamp Server and create file in the project folder and give name index.php.
Example:
<?php echo "Create your first project"; ?>
Output: Create your first project
index.php is the default display page, that open in the browser when project name enter in the URL after localhost. That’s like:
localhost/my_first_php_project/
if you create home.php file in the project folder then you need to enter in the URL:
localhost/my_first_php_project/home.php
Start PHP Project:
<?php echo phpinfo(); ?>
Output: display PHP version.
PHP start with <?php and end with ?>. All php code you can write under PHP starting and ending tag. If you want to display any text or elements, you need to set the texts or element in the echo statement or print statement.
In the PHP has some basic difference between PHP echo and print statements as well as how to use them to display output in the browser.