Post Page Advertisement [Top]



Click here to send WhatsApp On Unsaved Mobile Numbers For Free

PHP Variables

PHP Variables

It is very easy to understand the variables in PHP. To define variables in PHP add dollar sign ($) before the variable name like $age, $year, $gst, etc.

Syntax of assigning variable in PHP:

$varName = value;

or,

$varName1 = "Value";


How we can understand the variable types in PHP?

It is very easy to understand the variable types in PHP. The value in double inverted comma as a string value either you write any numerical value into double inverted comma. Always remember to put double inverted comma around the variables if you write any alphabet character, words or sentences. 

If you assign any value to the variable as integer or numeric value without double inverted comma then you can say that it is an integer value like $x = 5; This is Integer Variable in PHP.


If you assign any decimal value to an variable when it is known as float variable like $x = 3.4;


Rules of variable in PHP:

  • The name of the variable start with dollar sign ($)
  • The variable name must be start with underscore (_) or letter
  • The variable name is not start with number
  • A variable name cannot contain any a special character like &, #, @ etc.
  • A variable name only contains alphanumeric character and underscore (_)


Note: Variable names are case sensitive that means $age and $AGE are two different variables.


To print the the output of the variable we can use echo or print statement. For example:

Example 1:

<?php

    $var = "Hello Learner!!!" // String Variable

    echo $var;

?>

Output:

Hello Learner!!!


Example 2:

<?php

    $var = 1 // Integer Variable

    echo $var;

?>

Output:

1

Example 2:

<?php

    $var = 1.2 // Float Variable

    echo $var;

?>

Output:

1.2


PHP Syntax with examples


---

I hope you likable this nice post. Do not forget to share it together with your friends, the Sharing Button is below the post. Apart from this, if there's any downside within the intermediate, don't hesitate to request the Comment Box. we are going to be happy to help you.

I will continue to write more and more on this blog, so do not forget to make our blog BlogLearner as a bookmark (Ctrl + D) on your mobile or computer and subscribe to us to get all the posts in your email. Do not forget to share these posts, if you like it. You can facilitate us reach additional individuals by sharing it on social networking sites like Facebook or Twitter.


thanku
PHP Syntax with examples || PHP Tutorial 2


#php #php-tutorial #bloglearner #rrkksinha

No comments:

Post a Comment

Bottom Ad [Post Page]

rrkksinha.