123ArticleOnline Logo
Welcome to 123ArticleOnline.com!
ALL >> Computer-Programming >> View Article

Getting Started With Php: A Beginner's Guide To Your First "hello World" Program

Profile Picture
By Author: Shweta
Total Articles: 14
Comment this article
Facebook ShareTwitter ShareGoogle+ ShareTwitter Share

Introduction
PHP tutorial for beginners and professionals provides in-depth knowledge of PHP scripting language. Our PHP tutorial will help you to learn PHP scripting language easily.
This PHP tutorial covers all the topics of PHP such as introduction, control statements, functions, array, string, file handling, form handling, regular expression, date and time, object-oriented programming in PHP, math, PHP MySQL, PHP with Ajax, PHP with jQuery and PHP with XML.
What is PHP?
PHP is an open-source, interpreted, and object-oriented scripting language that can be executed on the server side. PHP is well suited for web development. Therefore, it is used to develop web applications (an application that executes on the server and generates the dynamic page.).
PHP was created by Rasmus Lerdorf in 1994 but appeared in the market in 1995. PHP 7.0 is the latest version of PHP, which was released on 28 November. Some important points need to be noticed about PHP as followed:
PHP stands for Hypertext Preprocessor.
PHP is an interpreted language, i.e., there is no need for compilation.
PHP can ...
... be embedded into HTML.
PHP is an object-oriented language.
PHP is an open-source scripting language.
PHP is a simple and easy-to-learn language.


Why use PHP?
PHP is a server-side scripting language, which is used to design dynamic web applications with MySQL database.
It handles dynamic content, database as well as session tracking for the website.
You can create sessions in PHP.
It can access cookies variables and also set cookies.
Using PHP language, you can control the user's to access some pages of your website.
It helps to encrypt the data and apply validation.
PHP supports several protocols such as HTTP, POP3, SNMP, LDAP, IMAP, and many more.

PHP Features

Install PHP
To install PHP, we suggest you install the AMP (Apache, MySQL, PHP) software stack. It is available for all operating systems. There are many AMP options available in the market that are given below:
WAMP for Windows
LAMP for Linux
MAMP for Mac
SAMP for Solaris
FAMP for FreeBSD
XAMPP (Cross, Apache, MySQL, PHP, Perl) for Cross Platform: It includes some other components too such as FileZilla, OpenSSL, Webalizer, Mercury Mail, etc.

How to install the XAMPP server on Windows
We will learn how to install the XAMPP server on the Windows platform step by step. Follow the below steps and install the XAMPP server on your system.

Step 1: Click on the above link provided to download the XAMPP server according to your window requirement.
Step 2: After downloading XAMPP, double-click on the downloaded file and allow XAMPP to make changes in your system. A window will pop up, where you have to click on the Next button.
Step 3: Here, select the components you want to install and click Next.


Step 4: Choose a folder where you want to install the XAMPP in your system and click Next
Step 5:nbsp;Clicknbsp;Nextnbsp;and move ahead
Step 6:nbsp; XAMPP is ready to install, so click on thenbsp; Nextnbsp;button and install the XAMPP.
Step 7:nbsp; A finish window will display after successful installation. Click on thenbsp;Finishnbsp;button
Step 8: Choose your preferred language
Step 9: XAMPP is ready to use. Start the Apache server and MySQL and run the PHP program on the localhost.
Step 10: If no error is shown, then XAMPP is running successfully

How to run PHP code in XAMPP
Generally, a PHP file contains HTML tags and some PHP scripting code. It is very easy to create a simple PHP example. To do so, create a file and write HTML tags + PHP code, and save this file with a .php extension.
All PHP code goes between the PHP tag. It starts with lt;?php and ends with ? gt;. The syntax of the PHP tag is given below:
Syntax:

How to run PHP programs in XAMPP PHP is a popular backend programming language. PHP programs can be written on any editor, such as - Notepad, Notepad++, Dreamweaver, etc. These programs save with a .php extension, i.e., filename.php inside the htdocs folder.

For example - p1.php.

As I'm using Windows, and my XAMPP server is installed in D drive. So, the path for the htdocs directory will be "D:\xampp\htdocs".

Step 1: Create a simple PHP program like "Hello World!".


Step 2: Save the file with the hello.php name in the htdocs folder, which resides inside the xampp folder.
Step 3: Run the XAMPP server and start the Apache and MySQL.
Step 4: Now, open the web browser and type localhost http://localhost/hello.php on your browser window.
Step 5: The output for the above hello.php program will be shown in the screenshot below.

Most of the time, PHP programs run as a web server module. However, PHP can also be run on CLI (Command Line Interface).


Credits – Shweta P. (Backend)
MetricsViews Pvt. Ltd.
MetricsViews specializes in building a solid DevOps strategy with cloud-native including AWS, GCP, Azure, Salesforce, and many more. We excel in microservice adoption, CI/CD, Orchestration, and Provisioning of Infrastructure - with Smart DevOps tools like Terraform, and CloudFormation on the cloud.
www.metricsviews.com

Total Views: 40Word Count: 809See All articles From Author

Add Comment

Computer Programming Articles

1. Unlock Your Potential With Xamarin Developer Certification
Author: EDCHART

2. Unlock Your Potential With Edchart's Flutter Developer Certification Exam - Free Test
Author: EDCHART

3. Navigating Success: Hiring Dedicated Php Developers For Your Next Project
Author: Quickway Infosystems

4. Cmmc Gap Analysis: Roadmap To Compliance
Author: Karmai

5. Hire Skilled Android App Developers
Author: John

6. How To Scrape Liquor Prices And Delivery Status From Total Wine And Store?
Author: Productdatascrape

7. Kotlin Certification |kotlin Developer Certification -by Edchart
Author: EDCHART

8. Empowering Careers: A Comprehensive Review Of Scope India Software Training Institute
Author: scope india

9. Double-sided And Multilayer Pcb Manufacturer: Rapid Circuit Leading The Way
Author: RICKY

10. 8 Reasons To Automate Your Cmmc 2+ Compliance With Karmai Consulting
Author: Karmai

11. Tips For Preparing Your Home For Nbn Installation
Author: hartnettcrews

12. How To Maximize Revenue By Web Scraping Tripadvisor Hotels Data?
Author: #WebScrapingTripAdvisorHotelsData

13. Secure And Comply: Essential Hipaa Compliance Checklist
Author: MakeForms

14. Enhancing Your App’s User Interface With React Native Ui Libraries
Author: matthew brain

15. Navigating The Divide: Data Security Management Vs Cloud Security Management
Author: Karmai

Login To Account
Login Email:
Password:
Forgot Password?
New User?
Sign Up Newsletter
Email Address: