Php Basic notes

Php Basic notes

Welcome is PHP ?

PHP: Hypertext Preprocessor (PHP) is a free, highly popular, open source scripting language. PHP scripts are executed on the server.

Just a short list of what PHP is capable of :

  • Generating dynamic page content
  • Creating, opening, reading, writing, deleting, and closing files on the server
  • Collecting form data
  • Adding, deleting, and modifying information stored in your database
  • controlling user-access
  • encrypting data

and much more !

Before learning php , you should have a basic understanding of HTML.


Why PHP ?

  • PHP runs on numerous, varying platforms, including Windows, Linux, Unix, Mac OS X, and so on.
  • PHP is compatible with almost any modern server, such as Apache, IIS, and more.
  • PHP supports a wide range of databases.
  • PHP is free!
  • PHP is easy to learn and runs efficiently on the server side.

PHP Syntax ?


<?php
  // PHP code goes here
?>


Php file Save extension ?


Php File Save extension is (.php)



Which text editor Use for Php ?


i recommend use notepad++ 


Let See 1st example of a simple PHP file.


-------------------------------------------
<html>
  <head>
    <title>My First PHP Page</title>
  </head>
  <body>
  
 <?php   
    echo "Hello World!";
  ?>

  </body>
</html>
-------------------------------------------


PHP Syntax


Alternatively, we can include PHP in the HTML <script> tag.

-------------------------------------------
<html>
  <head>
    <title>My First PHP Page</title>
  </head>
  <body>

  <script language="php">
    echo "Hello World!";
  </script>

  </body>
</html>
-----------------------------------------------

Note : The latest version of PHP removes support for <script language="php"> tags. As such, i recommend using <?php ?> exclusively.


PHP Syntax


You can also use the shorthand PHP tags, <?  ?>, as long as they're supported by the server.
<?
  echo "Hello World!";
?>

Note : <?php ?>, as the official standard, is the recommended way of defining PHP scripts.


What is Echo in Php ?


PHP has a built-in "echo" function, which is used to output text.
In actuality, it's not a function; it's a language construct. As such, it does not require parentheses.


Let's output a text.

-----------------------
<?php
echo "I love PHP!";
?>
-----------------------
Output : I love PHP!


PHP Statements

Each PHP statement must end with a semicolon.

<?php
  echo "A";
  echo "B";
  echo "C";
?>

Output: ABC

Note : Forgetting to add a semicolon at the end of a statement results in an error.


STAY TUNE I WILL ALSO PROVIDE MORE MATERIAL 


Post a Comment

0 Comments