PHP Tutorial by shreenath

                                          PHP

    * What is PHP?

        PHP is a server scripting language, which have different tool 
    to bulid dynamic and interactive Web.

    * What is XAMPP?
        XAMPP is the local server host by Apache. It provides service
    to developers for create and test their programs on local Web 
    Server.

    * What is Apache?
        Apache is the famous and widely used webserver software.
    It is open source software.

    * Advantages of Apache?
        1. Fast
        2. Reliable
        3. Secure
        4. Customizable

            XAMPP is the short form of the following:
                X : cross-platform
                A : Apache
                M : MySQL
                P  : PHP
                P  : Pearl

    XAMPP is an enviroment which helps to run PHP.

    * Proper way to create and open php file in vs code
                1.Open file mannager in your PC
                2.Open local disk/ XAMPP.
                3.Open XAMPP folder in  your  PC.
                4. go to htdoc.
                5. Create your project folder.
                6. Open it. 
        7. Right click in to this folder.
               8. Select empty document.
               9. and Create file of name "index.php"
               10. Go back to folder name.
               11. right click and select open with vs code.
               12. This is how we open php file.
       
        Syntax of PHP 

        < ? PHP 
        ? > 

        why php is used as back end language  ? 

        Because php runs at server and it can't display its logic to user . 

        Comments 

        What is Comments? 
        = Comment is the lines can't display on your GUI / page

        • How it is assigned?
        = there are 2 types of comment 
        1) single line Comment 
            single line comment is displayed using "//"

        2) multiple comment 
            Multi-line comment is displayed " / * This * / "
            This is used for only understanding to developer

        Variable - 

        Define- 
         Variable is a container that contains any type of value in it . 

        * How can we assign variables in php ?
          In other languages we have to give data types to our variable while assigning                                                  
          but in php we use simple " $ " this sign to assign variables.
          Also in php we don't need to write its data type be cause php is a dynamic
          language. It can directly take values.
          PHP understood its variable datatype values by its content. 

          Ex . $ variable = 2 ; 

          Here we declared also assigned value int to it.
          Ex. 
          

        * Rules for PHP variables:

         1] A variable starts with the $ sign, followed by the name of the variable
         2] A variable name must start with a letter or the underscore character
         3] A variable name cannot start with a number
         4] A variable name can only contain alpha-numeric characters and underscores
            (A-z, 0-9, and _ )                     
         5] Variable names are case-sensitive ($age and $AGE are two different variables)
         
        Output Variables ->
         The PHP echo statement is often used to output data to the screen.
         The following example will show how to output text and a variable:

         Example
           

        Variables Scope ->

         In PHP, variables can be declared anywhere in the script.
         The scope of a variable is the part of the script where the variable can be              
         referenced/used.

         * PHP has three different variable scopes:

           Local
           Global
           Static

         1] Local Scope ->
            A variable declared within a function has a LOCAL SCOPE and can only be  
           accessed within that function:

         Example ->
         Variable with local scope:

           Variable x inside function is: $x

"; } Test(); // using x outside the function will generate an error echo "

Variable x outside function is: $x

"; ?> 2] Global Scope -> A variable declared outside a function has a GLOBAL SCOPE and can only be accessed outside a function: Example -> Variable with global scope: Variable x inside function is: $x

"; } Test(); echo "

Variable x outside function is: $x

"; ?>

Leave a Reply