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. Reputation Management In The Digital Age: Protecting And Enhancing Your Law Firm’s ImageAuthor: jamewilliams
2. What Features Should I Look For In Wordpress Ecommerce Plugins?
Author: Rocket Press
3. Staying Updated With The Latest Gaming News
Author: Next Tech Plus
4. Game Development: Evolving Technologies And New Horizons
Author: Rick John
5. Why Svelte Is The Most In-demand Framework For Web Development?
Author: Why Svelte Is The Most In-Demand Framework For Web
6. Maximizing Ebay Sales With Maropost/neto And Pursuit Info Solutions
Author: rachelvander
7. The Importance Of Software Testing: Ensuring Quality In Development
Author: John Mathew
8. Sadhgurusilveroaks - The Best School In Nellore
Author: Sadhgurusilveroak
9. Website Development Using Kentico – Cloud First Headless Cms
Author: Website Development Using Kentico – Cloud First He
10. Shopify Experts In Melbourne: Elevate Your E-commerce With The Merchant Buddy
Author: themerchantbuddy
11. Web Development 3.0: Shaping The Future Of The Internet
Author: Backend Brains
12. Top College Erp In India Helps Colleges Operate More Efficiently
Author: CONTENT EDITOR FOR SAMPHIRE IT SOLUTIONS PVT LTD
13. "lcc Computer Education: Expert Java Coaching Center"
Author: Khushi Gill
14. Which Institute Is Best For Full Stack Developers In Bhopal?
Author: Shankar Singh
15. Micheal John
Author: micheal