It evaluates a string as PHP code.
Example
<?php
$lan = “phpcode”;
$text = ‘$lan’;
eval(“$value = “$text”;”);
echo $value;
?>
Output
phpcode
It evaluates a string as PHP code.
Example
<?php
$lan = “phpcode”;
$text = ‘$lan’;
eval(“$value = “$text”;”);
echo $value;
?>
Output
phpcode
Its an alias of the exit() and prints a message and exits the current script
Example
<?php
$fp = fopen(“test.xml”,”r”) or die(“Failed”);
?>
It checks whether a given named constant exists
Example
<?php
echo defined(“LAN”)?LAN:”Not defined”;
?>
Output
Not defined
It defines a constant
Example
<?php
define(“LAN”,”phpcode”);
echo constant(“LAN”);
?>
Output
phpcode
It returns the value of a constant
Example
<?php
define(“LAN”,”phpcode”);
echo constant(“LAN”);
?>
Output
phpcode
It checks if the script timed out
Example
<?php
if(connection_timeout())
echo “Timed out”;
?>
Its deprecated in PHP 4.0.5
It returns the current connection status
Example
<?php
echo connection_status ();
?>
It returns one of the follows
0 – CONNECTION_NORMAL – connection is running normally
1 – CONNECTION_ABORTED – connection is aborted by user or network error
2 – CONNECTION_TIMEOUT – connection timed out
3 – CONNECTION_ABORTED & CONNECTION_TIMEOUT
It checks whether the client has disconnected.
Example
<?php
if (connection_aborted())
error_log (“Connection is aborted”);
?>
It runs an XPath query on XML data
Example
<?php
$xml = simplexml_load_file(“test.xml”);
$xml->registerXPathNamespace(“msg”,”http://www.phpcodez.com”);
$result = $xml->xpath(“msg:web”);
?>
XML
<?xml version=”1.0″ encoding=”ISO-8859-1″?>
<web>
<server ver=”5″>Apache</server>
<lan>PHP</lan>
<client>Javascript</client>
</web>
It returns SimpleXMLElement object from an XML string
Example
<?php
$xmlstring = ‘<?xml version=”1.0″ encoding=”ISO-8859-1″?><lan>PHP</lan>’;
$xml = simplexml_load_string($xmlstring);
print_r($xml);
?>
Output
SimpleXMLElement Object ( [0] => PHP )