Now that you installed xampp it’s time to set up your project and write your very first php script.
First go to the server root path ( if you remember from the installing and setting up xampp post ) and inside it create a new folder, i will name it “tryphp”. Be careful with that name because it will be important in the future, i recommend to not use spaces or any kind of special characters. This folder will be your website’s root folder and it will contain scripts, resources and everything you will need for your website.
Note: In order to see your website you will need to open your browser and in the address bar type ” localhost/tryphp ” and you should see a blank page.
Now in your tryphp folder create an index.php file and open it with your text editor/IDE of your choice ( i will write a post and give you a list of free and payed IDEs)
If you know some basic html you know that every piece of text should be enclosed in some tags like “<body>content</body>” so that the browser can read it correctly, something similar is required in php too but here you only need one “tag” and that is <?php “php code” ?>
So, let’s write your first line of code that will make the server to output something in the browser:
<?php
echo “This is my first line of code in php”;
?>
The echo function in php is used to send information from the server to the browser, in this case if you save the file and refresh the page with your website, you will see the text “This is my first line of code in php” written in the browser.
So congratulations, you just wrote your first php code and it was a success, i hope that i make it easy to follow and if you have some recommendations or requests don’t hesitate to contact me. Cheers
One thought on “Your first php script”