PHP Lecture 3.....
String Interpolation is a quick shortcut, allowing to pop the value of a variable into a double quoted string. Ex:- <?php
$value =10;
echo "Value is: $value";
?>
>>Rules
1. Surround the variable name with spaces.
Ex:- <?php
$value=10;
echo"$value is good for you";
?>
2. Don't use single quotation marks - when you use single quotation marks , PHP does not apply string interpolation.
>> Constants In PHP....
1. Whose values can't be modified.
2. define() function is used to create a constant.
3. Syntax:- define("constant_variable", value, case-insensitive);
Ex:- a.) define("pi", 3.14); [Here "pi" is case sensitive]
b.) define("pi", 3.14, TRUE); [Here "pi" is non-case sensitive]
c.) define("site", "anime");
>> RULES...
- No need to start constant variable name with '$' sign.
- Name only starts with a letter and an underscore(_).
- Variable name cannot start with a number.
- It is case sensitive which implies that the variable num in lowercase is different from variable NUM in uppercase. But we can make it case insensitive.
- Constants are automatically global and can be used across the entire script.
- Can't use predefined constant name. e.g:- PHP_VER, PHP_anime etc.
- Can't use reserved keywords. eg:- else, if, etc.
>>Arithmetic/Math Operators...
Eg:-...
<?php
echo 5+6;
echo 6-2;
echo 6/3;
echo 7*1;
echo 6%2;
?>
Comments
Post a Comment