Posts

ch-3 CLI

every php code firstly run on server than shown on browser, thats why php called a server oriented programming. you already seen way to create output of php coding by using server.but there is one more way to show output of php code , that is CLI(command line interpreter) CLI helps to cerate desktop application. CLI is a software helps user to easily find out error  and also helps by saving time , because By CLI php code doesnot need to upload  php code on serever. CLI directly execute php code. php Command line version is known as, "(CLI )Command Line Interpreter" and server version is known as "(CGI) Command gateway Interface"

Function

<?php function add($a,$b) {        echo $a+$b; } add(2,3); ?> Outrput:5 <?php function add($a,$b) {        return $a+$b."<br>"; } $a =add(4,5); echo $a; ?> Output:9 Variable Variables: In function , here we can also use variable variables process. Where we can assign function name in another variable. For example:- <?php function add($a,$b) {        return $a+$b."<br>"; } $fun='add'; echo $fun(5,6); ?> Output:11 Here ‘add’ function name is assign in ‘$func’.

ch-5 data type

Data Type There are several data type works in php: 1. NULL 2. B oolean 3. Integer 4. Float 5. Array NULL: <?php $a; echo $a; ?> Output: Notice : Undefined variable: a Because here you did not define variable value.In case, if you don’t want to define variable value, you have to assign NULL . <?php $a=NULL; echo $a; ?> Output: Empty screen i.e nothing print on screen. <?php $a=FALSE; echo $a; $b=TRUE; echo $b; ?> Boolean: Boolean value hold conditional(TRUE and FALSE )value, where TRUE indicate 1 and FALSE indicate 0. Example:1 <?php $a=FALSE; echo $a; $b=TRUE; echo $b; ?> Output-1 Example:2 <?php $a=FALSE; echo $a; if($a) {        echo "hello"; } else {        echo "hii"; } ?> Output:hii Integer: Integer data type consider whole number either positive or negative. Unlike C, ph...

ch-4 variable in php

Variable in php Unlike C, php does not need data type before declare variable name. In php we can directly declare and define variable name. For example: <?php $a=10; $b=20; $c=$a+$b; echo $c; ?> Output:30 If you want to write string along with this output, So you can try below code <?php $a=10; $b=20; $c=$a+$b; echo "answer is   $c"; ?> Output: answer is   30 see above third output statement which enclosed within double quotes ("answer is   $c";) . here, in place of   double quotes if you use single quotes like (‘answer is   $c’;) it will print   (answer is   $c). for ex. <?php $a=10; $b=20; $c=$a+$b; echo ‘answer is   $c’; ?> Output: answer is   $c You can also store one variable value In another variable , and this process simply called variable variables. <?php $name="Gita Devi"; $$name=$name; echo $$name; $$$name=$$name; echo $$$name; ?...

Index

php syntax Output

ch-1Syntax

Syntax of Php If you code for php you need to write your php statement within (<?php   ?>) symbol For ex. <?php Statement 1 Statement 2 Statement 3 ?>

ch-2 Output

There are mainly two language construct available in php for print: a.    echo b.    print Pay attention here, echo and print is a language construct not a function.   Because print and echo no need to follow with brackets. Eg.   echo :- <?php echo “hello World”; ?> This Program simply print: hello World print: You may also use print function in php to print same statement “hello world” like: <?php print “hello World”; ?> This Program code also   simply print: hello World In both statement if you don’t use parenthesis, then it will show error , But if there you want to print single word like “hello”   only then it is allow, it means only single word without double quotes(“ ”)is allowed , or can say that “white space “ is not allowed without double quotes(“ ”). eg. print hello; O/p->hello Cannot use white space print hello world; You saw in uppercase both (pr...