![]() |
Introduction to PHP Programming Language |
What is PHP Programming Language?
• PHP Programming Language is an acronym for "PHP: Hypertext Preprocessor".
• PHP Programming Language is a generally utilized, open source scripting dialect.
• PHP Programming Language contents are executed on the server.
• PHP Programming Language is allowed to download and utilize.
PHP Programming Language is an astonishing and famous dialect!
It is sufficiently intense to be at the centre of the greatest blogging framework on the web (WordPress)!
It is sufficiently profound to run the biggest interpersonal organization (Facebook)!
It is additionally sufficiently simple to be an apprentice's first server-side dialect!
What is a PHP File?
• PHP records can contain content, HTML, CSS, JavaScript, and PHP code
• The PHP code is executed on the server, and the outcome has come back to the program as plain HTML
• PHP records have augmentation ".php"
What Can PHP Programming Language Do?
• PHP Programming Language can produce dynamic page content
• PHP Programming Language can make, open, read, compose, erase, and close records on the server
• PHP Programming Language can gather frame information
• PHP Programming Language can send and get treats
• PHP Programming Language can include, erase, alter information in your database
• PHP Programming Language can be utilized to control client get to
• PHP Programming Language can scramble information
With PHP Programming Language you are not constrained to yield HTML. You can yield pictures, PDF records, and even Flash films. You can likewise yield any content, for example, XHTML and XML.
Why PHP Programming Language?
• PHP Programming Language keeps running on different stages (Windows, Linux, Unix, Mac OS X, and so on.)
• PHP Programming Language is good with all servers utilized today (Apache, IIS, and so forth.)
• PHP Programming Language underpins an extensive variety of databases
• PHP Programming Language is free. Download it from the authority PHP asset: www.php.net
• PHP Programming Language is anything but difficult to learn and runs productively on the server side
What Do I Need?
To begin utilizing PHP Programming Language, you can:
· Find a web have with PHP and MySQL bolster
· Install a web server on your own PC and then install PHP and MySQL
Utilize a Web Host With PHP Support
On the off chance that your server has initiated bolster for PHP you don't have to do anything.
Simply make a few .php documents, put them in your web registry, and the server will naturally parse them for you.
You don't have to aggregate anything or introduce any additional apparatuses.
Since PHP is free, the most web has offer PHP bolster.
Set Up PHP on Your Own PC
However, if your server does not support PHP, you must:
- install a web server
- install PHP
- install a database, such as MySQL
The official PHP website (PHP.net) has installation instructions for PHP: http://php.net/manual/en/install.php
Basic PHP Syntax
A PHP script can write anywhere in the document.
A PHP script starts with <?php and ends with ?>
<?php
// PHP code goes here
?>
// PHP code goes here
?>
The default file extension for PHP files is ".php".
A PHP file normally contains HTML tags and some PHP scripting code.
Below, we have an example of a simple PHP file, with a PHP script that uses a built-in PHP function "echo" to output the text "Hello World!" on a web page:
Example
<!DOCTYPE html>
<html>
<body>
<h1>My first PHP page</h1>
<?php
echo "Hello World!";
?>
</body>
</html>
<html>
<body>
<h1>My first PHP page</h1>
<?php
echo "Hello World!";
?>
</body>
</html>
Note: PHP statements end with the semicolon (;).
Comments in PHP
A comment in PHP code is a line that is not read/executed as part of the program. Its only purpose is to be read by someone who is looking at the code.
Comments can be used to:
- Let others understand what you are doing
- Remind yourself of what you did - Most programmers have experienced coming back to their own work a year or two later and having to re-figure out what they did. Comments can remind you of what you were thinking when you wrote the code
PHP Programming Language supports several ways of commenting:
Example
<!DOCTYPE html>
<html>
<body>
<?php
// A single-line comment
# A single-line comment
/*
This is a multiple-lines comment block
that spans over multiple
lines
*/
// You can also use comments to leave out parts of a code line
$x = 5 /* + 15 */ + 5;
echo $x;
?>
</body>
</html>
<html>
<body>
<?php
// A single-line comment
# A single-line comment
/*
This is a multiple-lines comment block
that spans over multiple
lines
*/
// You can also use comments to leave out parts of a code line
$x = 5 /* + 15 */ + 5;
echo $x;
?>
</body>
</html>
PHP Case Sensitivity
In PHP, all keywords (e.g. if, else, while, echo, etc.), classes, functions, and user-defined functions are NOT case-sensitive.
In the example below, all three echo statements below are legal and equal :
Example
<!DOCTYPE html>
<html>
<body>
<?php
ECHO "Hello World!<br>";
echo "Hello World!<br>";
EcHo "Hello World!<br>";
?>
</body>
</html>
<html>
<body>
<?php
ECHO "Hello World!<br>";
echo "Hello World!<br>";
EcHo "Hello World!<br>";
?>
</body>
</html>
However; all variable names are case-sensitive.
In the example below, only the first statement will display the value of the $color variable, because $color, $COLOR, and $coLOR are treated as three different variables :
Example
<!DOCTYPE html>
<html>
<body>
<?php
$color = "red";
echo "My car is " . $color . "<br>";
echo "My house is " . $COLOR . "<br>";
echo "My boat is " . $coLOR . "<br>";
?>
</body>
</html>
<html>
<body>
<?php
$color = "red";
echo "My car is " . $color . "<br>";
echo "My house is " . $COLOR . "<br>";
echo "My boat is " . $coLOR . "<br>";
?>
</body>
</html>
0 comments:
Post a Comment