Unit V PHP
Unit V PHP
UNIT V
PHP
Unit Outcomes
<?php
static $x = 100;
echo $x;
?>
= Assignment $x = $y
+= Addition $x += $y
-= Subtraction $x -= $y
*= Multiplication $x *= $y
/= Division $x /= $y
%= Modulus $x %= $y
== Equal $x==$y
<?php <?php
<?php <?php
$x = 100; $x = 100;
$x = 100; $x = 100;
$y=200; $y=200;
$y=200; $y=200;
echo $x && $y; echo $x || $y;
echo $x and $y; echo $x or $y;
?> ?>
?> ?>
SINHGAD INSTITUTE OF MANAGEMENT MASTER OF COMPUTER APPLICATION
17
Operators in PHP
➢ String data type operators:
✓ String data type operator are used to perform operation on string values.
✓ PHP has two operators that are specially designed for strings.
<?php
<?php
$txt1 =“Hello”;
$txt1 =“Hello”;
$txt2 =“World”;
$txt2 =“World”;
echo $txt1.= $txt2;
echo $txt1. $txt2;
?>
?>
MASTER OF COMPUTER APPLICATION
22
Methods in PHP
• Never use GET method if you have password or other sensitive
information to be sent to the server.
• GET can't be used to send binary data, like images or word documents,
to the server.
• The data sent by GET method can be accessed using QUERY_STRING
environment variable.
• The PHP provides $_GET associative array to access all the sent
information using GET method.
<?php
if( $_GET["name"] )
{
echo "Welcome ". $_GET['name']. "<br />";
}
?>
we can accessing the cookies values in we cannot accessing the session values in
easily. So it is less secure. easily. So it is more secure.
setting the cookie time to expire the using session_destory(), we we will destroyed
cookie. the sessions.
<?php
if(!file exists("student_information.txt "))
{
die("File not found");
} else {
$file=fopen(" student_information.txt ","r");
}
?>
occurs in PHP.
➢ This function must be able to handle a minimum of two
parameters (error level and error message) but can accept up
to five parameters
error_function(error_level, error_message,
error_file, error_line, error_context)
Parameter Description
Required. Specifies the error message for the user-
error_message
defined error
Optional. Specifies the filename in which the
error_file
error occurred
Optional. Specifies the line number in which the
error_line
error occurred
Optional. Specifies an array containing every
error_context variable, and their values, in use when the error
occurred
<?php
error_reporting($reporting_level);
?>