UNIT - 1 PHP Basic 1
UNIT - 1 PHP Basic 1
BCA SEM – 2
WEB PROGRAMMING
Code : CS-09
<?php
$a=10;
$b="abc";
$_x='a';
$f=12.1544544;
echo $a,$b,$_x,$f;
echo "hello";
?>
1)Local Variable
2)Global Variable
3)Static Variable
$$x 200
32 Presented By : Dharmesh Kapadiya
PHP echo statement :
It is a language construct and never behaves like a function, hence no
parenthesis is required. But the developer can use parenthesis if they
want.
The end of the echo statement is identified by the semi-colon (‘;’).
It output one or more strings. We can use ‘echo‘ to output strings,
numbers, variables, values, and results of expressions. Below is some
usage of echo statements in PHP:
Displaying Strings: We can simply use the keyword echo followed by
the string to be displayed within quotes. The below example shows
how to display strings with PHP.
The (.) operator in the below code can be used to concatenate two
strings in PHP and the “<br>” is used for a new line and is also known
as line-break.
The PHP === Identical $x === $y Returns true if $x is equal to $y, and they are of the
same type
comparison
!= Not equal $x != $y Returns true if $x is not equal to $y
operators are
<> Not equal $x <> $y Returns true if $x is not equal to $y
used to
!== Not identical $x !== $y Returns true if $x is not equal to $y, or they are not
compare two of the same type
values > Greater than $x > $y Returns true if $x is greater than $y
(number or < Less than $x < $y Returns true if $x is less than $y
string) >= Greater than or equal to $x >= $y Returns true if $x is greater than or equal to $y
<= Less than or equal to $x <= $y Returns true if $x is less than or equal to $y
<=> Spaceship $x <=> $y Returns an integer less than, equal to, or greater
than zero, depending on if $x is less than, equal to,
or greater than $y. Introduced in PHP 7.
.= Concatenation
assignment
$txt1 .= $txt2 Appends $txt2 to
$txt1
if ($x > 0) {
echo "The number is positive";
}
?>
Output :
The number is positive
Syntax:
foreach (array_element as value)
{
//code to be executed
}
It can be used with loops ex-: for loop, It can be used with loops ex-: for loop,
while loop. while loop.
The break statement is also used in We can use continue with a switch
switch statements statement to skip a case.
1. Argument Function
2. Default Argument
3. Variable Function
4. Return Function
Output :
Sum is : 8
Call By Reference
function within another function
Recursive function
Output :
Print second argument: php
1. Variable Functions
2. String Function
3. Math Function
4. Date Function
5. Array Function
6. Miscellaneous Function
7. File handling Function