PHP Tutorial 01 : Learn about basics in PHP.

Let’s start PHP tutorial 01

PHP tutorial 01: Background Setup of the PHP.

  • Before Start the php we need to setup the php in your computer.
  • Therefore You have to download and install three things to setup the php in the computer

Let’s install these

  • php.
  • server.
  • MYSQL.

Using this link http://php.net/manual/en/install.php you can install PHP.

Next PHP tutorial 01: First PHP program.

<!DOCTYPE html>
<html>
<body>

<?php // Starting Statement of the php
$txt = "PHP";
echo "PHP Tutorial $txt!";
?> // End statement of the php

</body>
</html>

Then Php function ‘echo’ is using to output the text this is also like java ‘print’ function.

<!DOCTYPE html>
<html>
<body>
<h1>PHP Tutorial 01</h1>
<?php
echo "Hello World";
?> 
</body>
</html>

At last Php function is end with the semicolon (;) and between the start statement and end statement code body is including.

Finally PHP syntax and comments.

  • Here PHP keyword, function, defined function, classes names are not case sensitive.
  • Therefore Variables are case sensitive in the php.
  • Finally PHP keyword, function, classes and defined functions are not case sensitive Examples,
<!DOCTYPE html>
<html>
<body>
<?php
ECHO "PHP Tutorial 1<br>"; // Functions is not case sensitive.
echo " PHP Tutorial 1br>";
EcHo " PHP Tutorial 1<br>";
?> 
</body>
</html>
PHP tutorial 01

Then Variables are case sensitive in the php.

<!DOCTYPE html>
<html>
<body>

<?php
$size = "big";
echo " Elephants are " . $size . "<br>";
echo " Elephants are " . $SIZE. "<br>";
echo " Elephants are " . $siZE . "<br>";
?> 

</body>
</html>

PHP Comments.

  • PHP Has two types of comments, which are, single line comments and multiple line comments.
  • Comments is using in the code to understand the code for others and check what did by yourself.

Single Line comment Examples.

yourself.
<?php
// This is a single-line comment

# This is also a single-line comment
?>
https://www.javatpoint.com/php-comments

Multiple Lines Comment Example.

<?php
/*
This is a multiple-lines comment block
that spans over multiple
lines
*/
?>

PHP Variables.

  • Variables are starting with the $ and variables are storing the data.
  • Then we Cannot start with the numbers.
  • Variables are case sensitive.
  • Contain alpha-numeric characters and underscores.
  • Fifth popular language.
<!DOCTYPE html>
<html>
<body>

<?php
$txt = "PHP Tutorial 1";
echo "PHP " . $txt . "!!";
?>

</body>
</html>

PHP Tutorial 02.

PHP Session is best way to store the information in variable.

In the web server cannot recognize you because HTTP address does not maintain your state. But this php session variable help to store your data by avoiding above problem. This session can hold the one user information to all pages in the application.

Session starting function is session_start().

Session php global variable $_SESSION.

If you want you can modify the session variables.

Session can destroy using session_unset() and session_destroy().

7 thoughts on “PHP Tutorial 01 : Learn about basics in PHP.”

Leave a Reply

Your email address will not be published. Required fields are marked *