PHP
Run our First PHP Program
Hi, everyone, today we’ll start our first PHP program. Let’s make our first php application.
¶File Structure:
- Let’s create a folder in ypur
xampp/htdocs
namedphpclass
. - Then inside that folder create a file called
class1.php
. - And this
.php
is the extension of PHP file. - Every php file, we must have to declare as
.php
. PHP interpretor can interpret the file if it sees a.php
file.
¶PHP Code:
So, in our C:/xampp/htdocs/phpclass/class1.php
would be like this -
<?php
echo "Hello World. Welcome to PHP";
?>
¶Run on Browser
Now, go to your browser and run - http://localhost/phpclass/class1.php
And you’ll see this text in the browser -
Hello World. Welcome to PHP
Awesome, we’ve made our first PHP program and view that on the browser.
¶PHP Code with HTML:
So, after our first PHP program, it’s great right. Let’s improve it a little bit. PHP is a scripting language, we know. It’s actually an embedded language, means - it can be embedded inside HTML. WOW let’s see the above PHP code will work in a simple HTML file -
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PHP Class 1</title>
</head>
<body>
<?php
echo "Hello World. Welcome to PHP";
?>
</body>
</html>
¶Run on Browser
Now, in browser, reload again - http://localhost/phpclass/class1.php
And you’ll see this text in the browser -
Hello World. Welcome to PHP
Great, so we’ve seen that we can inject PHP inside of an HTML body
tag.
Install PHP or Xampp in Windows / Linux / Mac - Easy PHP Server setup
Variables in PHP - How to Create, Rules and Examples
All Tutorials in this playlist
Popular Tutorials
Categories
-
Artificial Intelligence (AI)
11
-
Bash Scripting
1
-
Bootstrap CSS
0
-
C Programming
14
-
C#
0
-
ChatGPT
1
-
Code Editor
2
-
Computer Engineering
3
-
CSS
28
-
Data Structure and Algorithm
18
-
Design Pattern in PHP
2
-
Design Patterns - Clean Code
1
-
E-Book
1
-
Git Commands
1
-
HTML
19
-
Interview Prepration
2
-
Java Programming
0
-
JavaScript
12
-
Laravel PHP Framework
37
-
Mysql
1
-
Node JS
1
-
Online Business
0
-
PHP
28
-
Programming
8
-
Python
12
-
React Js
19
-
React Native
1
-
Redux
2
-
Rust Programming
15
-
SEO - Search Engine Optimization
1
-
Tailwind CSS
1
-
Typescript
10
-
Uncategorized
0
-
Vue JS
1
-
Windows Operating system
1
-
Woocommerce
1
-
WordPress Development
2
Tags
- Artificial Intelligence (AI)
- Bash Scripting
- Business
- C
- C Programming
- C-sharp programming
- C++
- Code Editor
- Computer Engineering
- CSS
- Data Structure and Algorithm
- Database
- Design pattern
- Express JS
- git
- Git Commands
- github
- HTML
- Java
- JavaScript
- Laravel
- Mathematics
- MongoDB
- Mysql
- Node JS
- PHP
- Programming
- Python
- React Js
- Redux
- Rust Programming Language
- SEO
- TypeScript
- Vue JS
- Windows terminal
- Woocommerce
- WordPress
- WordPress Plugin Development