Write Your First PHP Program

A “ Hello World” program, as the first program, has become a culture whenever learning a new programming language.

You need a certain environment to write PHP scripts. Since PHP is a server-side language, it requires a web server for the script to run. In this article, you will create a local xampp webserver.

Write and Run a “ Hello World” Program

Now that you have set up the environment for PHP and learned its syntax lets move onto creating the Hello World program.
Follow this step-by-step to create your PHP program:
  • Open the directory where XAMPP is installed. By default, XAMPP is installed in the C: drive.
  • Open the XAMPP folder and locate a folder named “htdocs” in it.
  • Inside htdocs folder, create a folder and name it anything suiting your project. Here, it has been named as demo
  • post image

  • Create a file named index.php inside the demo folder. Since PHP is embedded into HTML codes, write the following HTML code along with the PHP script.
  • below code, echo is used to print the string in front of it.

    post image

  • Save the file and open your web browser and type localhost/ followed by the folder name that you created and hit enter.
  • post image

    Rasika Preethiraj

    A technophile at icrony since 2012, In a quest to programmatic automations for scaled organisations through the use of python, php, autoit and machine learning


    Comments


    Post a Comment



    Trending

    Latest Posts

    Tags

    Newsletter

    Subscribe to our newsletter for good news, sent out every month.