ALL >> Computer-Programming >> View Article
Getting Started With Php: A Beginner's Guide To Your First "hello World" Program
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
Add Comment
Computer Programming Articles
1. How To Choose The Right Coding Institute In BhopalAuthor: Shankar Singh
2. Streamline Your Finances With The Best Bookkeeping Software In Zambia
Author: Doris Rose
3. Maximizing Ebay Success With Maropost/neto Partnerships
Author: rachelvander
4. The Rise Of Ai In Modern Gaming
Author: Saira
5. Enhancing Business Efficiency With Entrust Network: Singapore’s Premier It Solutions Partner
Author: Entrust Network Services
6. Ai And Ml Training: Empowering Your Career With Infograins Tcs
Author: Infograins tcs
7. How To Evaluate Coding Institutes In Bhopal?
Author: Shankar Singh
8. Revolutionizing Delivery Services With Application Development
Author: basheer ansari shaik
9. How Google Cloud Platform Aids Businesses And Keeps Its Data Safe?
Author: Stuart
10. Custom Web Development Solutions In Surat For Growing Businesses
Author: sassy infotech
11. Video Streaming App Development: 12 Key Features, Architecture And Cost
Author: Byteahead
12. Understanding Google Analytics Events
Author: Byteahead
13. Types Of Learning Management Systems
Author: Byteahead
14. How To Choose The Best Coding Institute In Bhopal?
Author: Shankar Singh
15. Top Tech Trends Real Estate Companies Should Focus
Author: Byteahead