PHP 5 Tutorial

php

PHP Constants



                     A constant is an identifier (name) for a simple value. The value cannot be changed during the script. A valid constant name starts with a letter or underscore (no $ sign before the constant name).


Create a PHP Constant


To create a constant, use the define() function.



Syntax


<?php define("GREETING", "Welcome to techomania143.blogspot.com!");echo GREETING;?>

The example below creates a constant with a case-insensitive name:
<?php
define("GREETING", "Welcome to techomania143.blogspot.com!", true);
echo greeting;

Constants are Global

<?php
"GREETING""Welcome to techomania143.blogspot.com!");
function myTest() {
    echo GREETING;
}
myTest();

                                                                Thank You

                                                                                                               Date:07-01-2019


PHP String Functions

          
              There are actually 5 string built in functions they are :-

                      1) To find the length of a string we use strlen()
                          Ex:<?php
                                  echo strlen("Hello world");
                                 ?>

                      2) To count the number of words in a strings we use str_word_count() 
                          Ex:-<?php
                                     echo str_word_count("Hello world");
                                   ?>

                      3) To reverse the string we use strrev()
                           Ex:-<?php 
                                     echo strrev("Hello world");
                                    ?>

                      4) To search for a specific Text in a string we use strpos()
                          Ex:-<?php
                                      echo strpos("Hello world","world");
                                   ?>

                      5) Replacing a text with a string we use str_replace()
                          Ex:-<?php
                                     echo str_replace("world","Cool","Hello world");
                                   ?>
                                         
                                                           Thank You
                                                                                                           Date:04-01-2019

Data Types

                           
               The variables can store data of different types, and different data types can do different things. 
               The different data types that are supported are 
   1. String
   2. Integer
   3. Float
   4. Boolean
   5. Array
   6. Object
   7. Null
   8. Resource

1.String:- 

                A string is a sequence of characters 
      Ex:- <?php
               $x="Hello World!";
               $y='Hello World!';
               echo $x;
               echo "<br>";
               echo $y;
            ?>

2. Integer:-

              An integer data type is a non-decimal number between -2,147,483,648 and 2,147,483,647.

Rules for integers:

*)An integer must have at least one digit
*)An integer must not have a decimal point
*)An integer can be either positive or negative
*)Integers can be specified in three formats: decimal, hexadecimal  or octal .
             Ex:-<?php 
                     $x=8763;
                     var_dump($x);                  //Here this var_dump function is used to display the                                                                             //datatype of the particular variable 
                       ?>

3. Float:-

          A float (floating point number) is a number with a decimal point or a number in exponential form.
         Ex:-<?php 
                     $x=20.054;
                     var_dump($x);                  //Here this var_dump function is used to display the                                                                             //datatype of the particular variable 
                   ?>

4. Boolean:-

         A Boolean represents two possible states: TRUE or FALSE.
         Ex:-$x = true;
                $y = false;

5. Array:-

         An array stores multiple values in one single variable.
         Ex:-<?php 
                 $bikes = array("Bajaj","Honda","BMW");
                 var_dump($cars);
                  ?>

6. Object:-

         An object is a data type which stores data and information on how to process that data.
         Ex:-<?php
              class bikes {
                      function bikes() {
                                     $this->model = "Bajaj";
                                                 }
                               }

                     // create an object
             $herbie = new bikes();

                    // show object properties
            echo $herbie->model;
                 ?>

7. Null:-

        Null is a special data type which can have only one value: NULL. A variable of data type NULL is a variable that has no value assigned to it.
        Ex:-<?php
                        $x = "Hello world!";
                        $x = null;
                        var_dump($x);
                 ?>

8. Resource:-

         The special resource type is not an actual data type. It is the storing of a reference to functions and resources external to PHP.

                                                  THANK YOU
                                                                                                    Date:-03-01-2019

              The next blog will we written tomorrow same time so to get every day notification click on the follow button on the right.

               As i have not given the examples for these variables so today i am going to
<?php
$name="Technomania143";
echo "My blog name is" .$name. "check it out";
?>

And another example
<?php
$a=10;
$b=20;
echo $a + $b;
?>
Try to execute these and if you get the output then comment the ans below
                                                    THANK YOU
                                                                                    Date:-02-01-2019

PHP - Variable Types



  • All variables in PHP are denoted with a leading dollar sign ($).
  • The value of a variable is the value of its most recent assignment.
  • Variables are assigned with the = operator, with the variable on the left-hand side and the expression to be evaluated on the right.
  • Variables can, but do not need, to be declared before assignment.
  • Variables in PHP do not have intrinsic types - a variable does not know in advance whether it will be used to store a number or a string of characters.
  • Variables used before they are assigned have default values.
  • PHP does a good job of automatically converting types from one to another when necessary.
  • PHP variables are Perl-like.
                                                      Thank You For Visiting
                                                                                                                              
                                                                                                                       Date:-09-12-2017


                 In this tutorial i am going to discuss regarding how the html tags could be used in the php pages and why do we need to use html tags so lets start 

<html>
     <head><title>Trial</title></head>
          <body>
                <center>
                           <?php
                                        echo "Hello";
                              ?>
                </center>
         </body>
</html>

                    If we write the php code without html tags and php the display would be in a default manner(top left corner). if we use these tags then we could align the text and format the data.
  
                    You must save the file in same php format and under xampp/htdocs/Your Folder name(if there are any). Execution of this code is same as above.

                      I am explaining them in a very short and easy manner if you guys think you need briefer explanation then comment below   
                                                     

                   First run the control panel and run the services Appache and mysql.
                  
                   So if you guys have installed the xampp then just copy the below code and paste it on the text editor like notepad.

<?php
echo "Hello";
?>

                                    And save the file with .php extension and save it in C:\xampp\htdocs folder the file must be saved in htdocs if it is not saved there then it will not going to work.
                                    After saving open the browser and type http://localhost/hello.php this URL. While you are typing this you must be offline .

                                 If its not working then comment below.
                       
                                                      Thank you
                                                                                                        Date:-25-11-2017


    Hello guys welcome you all to this blog ,
                  In today's tutorial i will discuss regarding the basics of php as i couldn't use the dimond braces in the blog i will give this link below in the comment from where you guys could download the code i will just going to explain what they are 

<?php                    :-This will specify the start of the php script
statements                                    :-Here the logics are written
? >                           :-End of the php tag


                                           Before we start with the php scripting you guys need to download and install the xampp software as your Laptop/PC's will work as the client but its a server side scripting so by installing xampp or wamp your pc/laptop will work as the server. So only after installing that software you could run the php codes.
                                   Want to know whats client and server click here
                  
                                                              Thank You
                                                                                                       Date:-17-10-2017


Welcome guys to the blog,
           In this tutorial i am going to discuss regarding the php

         PHP is elaborated as "PHP hypertext Preprocessor".PHP was first written in C programming language by Rasmus Lerdorf in 1994 for monitoring his online resume and related personal information, at that time the PHP was named as "Personal Home Page".
     
         As the days goes on the PHP got evolved from versions to version like PHP 1,PHP 2.0 and soon now the present version being used is PHP 7.

          Before starting php we have to know the basics of html,css and js

      If you guys are interested to learn this then please subscribe by clicking on the right.
Subscription
THANKYOU FOR VISITING

---------------------------------------IGNORE THE TAGS BELOW----------------------------------------------
php, php 7 allink, php allink, php datatypes, php scripting, php5, php5 tutorial, php7, php7 allink, php7 tutorial, server side scripting, wamp installation, xampp installation, 

php, php 7 allink, php allink, php datatypes, php scripting, php5, php5 tutorial, php7, php7 allink, php7 tutorial, server side scripting, wamp installation, xampp installation, 

php, php 7 allink, php allink, php datatypes, php scripting, php5, php5 tutorial, php7, php7 allink, php7 tutorial, server side scripting, wamp installation, xampp installation, 

php, php 7 allink, php allink, php datatypes, php scripting, php5, php5 tutorial, php7, php7 allink, php7 tutorial, server side scripting, wamp installation, xampp installation, 

php, php 7 allink, php allink, php datatypes, php scripting, php5, php5 tutorial, php7, php7 allink, php7 tutorial, server side scripting, wamp installation, xampp installation, 

php, php 7 allink, php allink, php datatypes, php scripting, php5, php5 tutorial, php7, php7 allink, php7 tutorial, server side scripting, wamp installation, xampp installation, 

php, php 7 allink, php allink, php datatypes, php scripting, php5, php5 tutorial, php7, php7 allink, php7 tutorial, server side scripting, wamp installation, xampp installation, 

php, php 7 allink, php allink, php datatypes, php scripting, php5, php5 tutorial, php7, php7 allink, php7 tutorial, server side scripting, wamp installation, xampp installation, 

Comments