![]() In the above code, “echo” is used to print the string in front of it.Ĩ. Since PHP is embedded into HTML codes, write the following HTML code along with the PHP script. Create a file named “index.php” inside the demo folder.ħ. Locate to C:\xampp\htdocs and select the “demo” folder you created.Ħ. Now open Visual Studio Code and click on “open folder”.ĥ. Inside that “htdocs” folder, create a folder and name it anything suiting your project.Ĥ. Open the XAMPP folder and locate a folder named “htdocs” in it.ģ. By default, XAMPP is installed in the C:\ drive.Ģ. Open the directory where XAMPP is installed. Now that you have set up the environment for PHP and learned its syntax let’s move onto creating the Hello World program.įollow this step-by-step to create your PHP program:ġ. It starts with while the code goes in between.įor every PHP file, the default extension code is ".php".Ī PHP file usually contains HTML codes with PHP scripts embedded into them. PHP SyntaxĪ PHP script is very similar to how HTML codes are written. Now, have a look at the syntax for writing PHP scripts. Eg: Atom, Notepad etc.ĭownload the Visual Studio Code from the official website. You may also download any code editor of your choice. You will use Visual Studio Code as the code editor. Now, to write the code, you need a code editor. After installation, open the XAMPP control panel and start the Apache webserver. Download and install XAMPP from the official website.Ģ. XAMPP is also used to set up a MySQL database, which you will learn in the later sections.ġ. ![]() You will be mainly using it for creating a local web server for this tutorial. As you will learn with experience, problems are almost always the result of subtle mistakes in entering the PHP code.XAMPP is an open source software which stands for: ![]() Something as simple as a missing character can result in no content being generated by the PHP module. If you do not see the expected output in your browser window then go back and check your file. If you see something like the above in your browser then you have successfully created and executed your first embedded HTML script. When you load this page into your browser you should see something like the following: Save this file as example.php and upload it to your web server. Open your editor and create the following HTML file: We will now go on to create another script that is embedded into an HTML page. There are vastly superior resources available on the internet to assist in installing PHP than we could never match in this book.Ī healthy PHP installation should result in output similar to the following:Īs you may have realized, by testing the PHP module on your web server you have already crafted your first PHP script. If you run your own web server consult the documentation for your particular type of server (Apache, Microsoft IIS etc) for details on integrating the PHP module. If you use a web hosting company, check with them to see if your particular hosting package includes PHP support (sometimes PHP support is only provided with premium hosting packages so you may need to upgrade). If you do not see this information it is possible you do not have the PHP module integrated into your web server. If all is well with your PHP installation you will see several pages of detailed information about your PHP environment covering topics such as how and when the PHP module was built, the version of the module and numerous configuration settings. Once you have done this open a browser and go to the URL for this file. Save this file as phpInfo.php and upload it to a location on your web server where it will be accessible via a web browser. This PHP script calls the built-in PHP phpInfo() function, the purpose of which to output information about the PHP pre-processing module integrated into your web server.
0 Comments
Leave a Reply. |