Welcome to PHPBash | Helping You to Become an Expert in PHP Programming. In this PHP Tutorial for beginners and professionals, I will Cover, How to Write First PHP Program or Script?, How to Execute PHP Program in XAMPP?,What PHP File contains? etc. To Run Your PHP Script, You must be ready with PHP Environment like XAMPP.
If you have not Installed XAMPP till now, You can Visit latest tutorial on Installation of PHP with XAMPP in Windows 7/ Windows 10 from our blog. By Following instructions given in tutorial, you will be able to download and install XAMPP on Windows 7 / Windows 10.
How to Beginning with your First PHP Program?
This PHP tutorial covers all the topics of PHP Introduction such as
1. What is PHP Script/ PHP Program?
2. What PHP file Contains?
3. Editors for Writing PHP Program
4. Creating First PHP Program
5. Executing PHP Program in XAMPP
Lets start this PHP tutorial with question What is PHP Script/ PHP Program?
What is PHP Script/ PHP Program?
<?php
and ?>
are Interpreted by PHP Parser on Web Server. The <?php
and ?>
is called PHP Block. It Starts with <?php
Ends with ?>.
While Embedding In HTML, you may have any number of PHP blocks as per your requirements.Writing First PHP Program in Sublime Text Editor- hello.php file After writing above PHP script, save it with name hello.php in Root Directory of XAMPP. For Example, As in this Example I used windows, and my XAMPP server is installed in C drive. So, the path for the Root Directory i.e. htdocs directory will be "C:\xampp\htdocs". Now your first PHP Script is Ready. You are ready to Execute it. Lets see it now. What PHP file Contains?PHP files may contain plain text, HTML, CSS, JavaScript, and PHP code itself. PHP files can be saved with extension ".php" in the root directory of Web Server. If you want more details, check our tutorial Introduction to PHP. PHP FIle Screenshot: Showing HTML,CSS,JavaScript, PHP Editors for Writing PHP ProgramThere are different IDE's and Editors are available for writing PHP Script. Basically, an Integrated Development Environment or IDE is a full package with which you are able to write php script, Interpret PHP Script, execute and debug PHP Script code at the same place. On the other hand, in contrast, Code Editor is a text editor with limited features that allows writing code, either through native capabilities or through optional plugins. They are as follows: Popular IDE's for PHP Project DevelopmentPopular Code Editors for PHP Project Development
Executing PHP Program in XAMPPAs PHP is used to Develop Web Applications, so PHP program runs on a web browser such as - Chrome, Firefox,Opera, Internet Explorer etc. The Following Steps can be followed to run the your first PHP program hello.php. Step 1: Create a simple PHP program as created above hello.php file Step 2: Save the file with hello.php name in the Web Servers Root Directory htdocs folder only, which resides inside the xampp folder. For Example,"C:\xampp\htdocs" as described earlier. Step 3: Start the XAMPP server and followed by starting the Apache and MySQL. Step 4: Now, open your web browser and type localhost http://localhost/hello.php on your browser window's address bar. Step 5: The output for the above hello.php program will be shown as the screenshot below: |
<html> <head> <title>Welcome to PHPBash!!!</title> </head> <body> <?php echo '<p>Welcome to PHPBash!!!</p>'; ?> </body></html>
Comments
Post a Comment
Thank you so much.