When any word or string is to be searched in any array, we use in_array function. It retunes boolean value.
Example :
$str=”Hello”;
$arr= array(‘Hello’,’Bye’,’Hi’);
$rslt= in_array($str,$arr);
a). Concatenation (.) operator : This operator is used for combining more than one strings or variables.
b). = assignment operator : This operator is used assign right side value to left side variable.
When we have to check if the two variables are of same value and same type, we use ‘===’. In another word, it’sused forstrict type checking.
To open the file in read only mode, first the fopen() function needs to be used for opening the file. It needs two arguments stating first the file name and then mode in which to operate. “r” mode opens the file for reading only and places the file pointer at the beginning of the file.
Using this variable we can check whether the PHP variable is an instantiated object of a certain class or not. It returns Boolean value.
preg_match() is PHP’s regular expressionfunction which is used for finding a string on the basis of given parameter. If the match is found, then value is returned true else false.
When we try to print any object directly,we get cannot convert class to string.
If we use _toString() before function name, now echoing the object is possible.
Example :
class Assets{
protected
$queue = array();
public function add($script){
$this->queue[] = $script;
}
public function __toString(){
$output = ”;
foreach($this->queue as $script){
$output .= ‘‘;
}
return $output;
}
}
$scripts = new Assets();
echo $scripts
time() function provides complete information about current date and time.
ini_set(‘display_errors’, 1);
error_reporting(E_ALL ^ E_NOTICE);
PHP’s isset function is used to check if the variable is set or not.
Both are string functions of PHP. When strstr() is is applied with argument and the argument matches with the string, it displays rest of the string text from there.
Example :
Output : World!
Both are same except that stristr is case in-sensetive while strstr is case sensitive.
In while Loop condition is checked first and then displays the result. So, in this case if the condition is false, it does now show any result.
Interfaces are defined for common pattern. In interfaces only the variables are decaled and not implemented. The implementing class function will use the pattern.
Interfaces are defined same way as class except interface keyword instead of class keyword.
Both regular expression functions of PHP. The difference is that the function eregi_replace() is not case sensitive while ereg_replace() is case sensitive.
ereg() function takes two parameter, in the first parameter regular expression string pattern is used and in the second parameter, the string. If the pattern matches with the string, it returns true or else false.
ereg() and eregi() both are identical except that ereg is not case sensitive while ereg is case sensitive.
Though, there are several types of errors in PHP but the main ones are notices, warnings and fatal errors. If there is warning and notices in the file, the program can still run, but if there is fatal error, program stops executing.
Using getFile() method of Exception class which returns source filename.
Simply changing the date of the cookie to thepast date causes the cookie to expire.
IF NOT EXISTS is used to check if the table already created or not.
URL re-writing is possible through htaccess. URL re-writing is feature of apache and it must be enabled on the server.
a) $x = 10;
echo $x++. ‘ ‘.$x;
b) $y = 10;
echo ++$y
echo ++$y. ‘ ‘ .$y;
Answer: a)The result is 10 and 11
b) 11 and 11
Image data is saved in MySql in blog data type
Classroom
Online
WeekEnd