Mohamed Sobhy
Jan 6, 2020

In this tutorial, I am going to explain how to write your first php web page with programming example for beginners and where to write php code. After setting up your website (by activating your domain on a host server - sign up & subscribe to read more), open any text file editor. You could simply use your notepad program which is already provided in all computer systems; click start on lower left of screen and search for "notepad".

How to write your first php web page with code example

Once opened your text editor, suppose a new empty file is shown, otherwise go to file > new in the top toolbar and write the below lines.

First php program or code example lines

echo "This is my first words to world!";

Explanation of the above php code lines

How to save a php coding file & where to write php code

Now, save the file in your main director folder provided by the host and name it as "index.php". The file extension ".php" is important to inform the server to direct this file to the proper translator as to process it back with readable results in the browser. In such case, the php translator is called "Apache" and used by any server. While, file name "index" is the default informing the server that this is the main file to be loaded first without mentioning it in the url (link address or path), as will follow.

What is displayed if missing any of php expressions ?

Not following the above expression orders will end with errors displayed in browser, mainly in the absence of "<?php" opening expression, the above code block will be displayed as it is with being processed.

How to load php file in browser

Open your browser, write in the top url address bar the folder path for example http://localhost/my-site-1/ in case of using a simulation program on your computer like wamp or similar. Note that the previous url exactly matches http://localhost/my-site-1/index.php as referred to before. Then, press enter in order to load the saved file in the browser. Once the file is loaded, suppose it will only show the following string:

This is my first words to world!
Thank you for reading the above article. Please let us know your comments below.
Subscribe to follow the next tutorial : What meant by variables in Php >>>


  • Practical Experience
About the author

Mohamed Sobhy

Mohamed is a freelance web designer, recreational software developer, author and CEO of . Also, has passion to learn and transfer the know-how of every valuable thing.
Views: 1446
0 Comment Guest
Recommend 0
Sort by Newest
Be the first to say something...

Ask Community

Ask questions and Share knowledge with Community

Find below recent posts for automation solutions with questions and answers by community. You can search in past threads or post new question about your assignment with detailed description, and always could mark your question as request. Sharing knowledge are highly appreciated by answering on others questions, and in return awards will be decided.

× Close