tag:blogger.com,1999:blog-3572264569702140792024-03-13T09:06:02.570+05:30Best Online Tutorials | Source codes | Programming LanguagesBest Online tutorials on all programming languages like HTML, CSS, ASP, JSP, JAVA, VB, VB.NET, AJAX, XML, PHP, SQL, XML, XHTML, JAVASCRIPTUnknownnoreply@blogger.comBlogger1455125tag:blogger.com,1999:blog-357226456970214079.post-9346929757220121642023-07-29T10:23:00.011+05:302023-07-29T10:23:49.247+05:30PHP - Complete reference for beginners<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: left;">
<div style="text-align: justify;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLxNahFFNavvD3cvulHXrwd_WCm7olFkFZa12ZHJ0wGiQyS-5sqfoxdfoocXPgzBFVlj5mxrl0N-1FhzdBXKcfEP_phQggpHW7LPc8bTa0ayUA6Q6FCjVMlmRpSGbC523_YXwFxv1dLAs/s1600/php+logo+1000sourcecodes.com.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="209" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLxNahFFNavvD3cvulHXrwd_WCm7olFkFZa12ZHJ0wGiQyS-5sqfoxdfoocXPgzBFVlj5mxrl0N-1FhzdBXKcfEP_phQggpHW7LPc8bTa0ayUA6Q6FCjVMlmRpSGbC523_YXwFxv1dLAs/s320/php+logo+1000sourcecodes.com.jpg" width="320" /></a><b>PHP</b>
is a general-purpose server-side scripting language originally designed
for Web development to produce dynamic Web pages. It is one of the
first developed server-side scripting languages to be embedded into an <a href="http://www.1000sourcecodes.com/2012/09/html-complete-tutorials-for-beginners.html" target="_blank">HTML</a>
source document rather than calling an external file to process data.
The code is interpreted by a Web server with a PHP processor module
which generates the resulting Web page. It also has evolved to include a
command-line interface capability and can be used in standalone
graphical applications.
PHP can be deployed on most Web servers and also as a standalone shell
on almost every operating system and platform free of charge. A competitor to <b>Microsoft's Active Server Pages </b>(ASP) server-side script engine and similar languages, PHP is installed on more than 20 million Web sites and 1 million Web servers. Software that uses PHP includes <b>MediaWiki</b>, <b>Joomla</b>, <b>Wordpress, Concrete5</b>, <b>MyBB,</b> and <b>Drupal.</b></div>
<div style="text-align: justify;">
PHP was originally created by <b>Rasmus Lerdorf</b>
in <b>1995</b>. The main implementation of PHP is now produced by The PHP
Group and serves as the formal reference to the PHP language.PHP is free software released under the PHP License, which is incompatible with the <b>GNU General Public License</b> (GPL) due to restrictions on the usage of the term <i>PHP</i> </div>
<h3>
PHP Fundamentals</h3>
</div>
<ol style="text-align: left;">
<li>PHP General Introduction </li>
<li>PHP Variables</li>
<li>PHP Syntax</li>
<li>
PHP String</li>
<li>
PHP Operators</li>
<li>
PHP If...Else Statements</li>
<li>
PHP Switch Statement</li>
<li>
PHP Arrays</li>
<li>
PHP Looping</li>
<li>
PHP Functions</li>
<li>
PHP Forms and User Input</li>
<li>
PHP $_GET</li>
<li>
PHP $_POST</li>
<li>
PHP Date()</li>
</ol>
<h3>
File Handling and Exception Handling with PHP</h3>
<ol style="text-align: left;">
<li>PHP Include File </li>
<li>PHP File Handling</li>
<li>
PHP File Upload</li>
<li>
PHP Cookies</li>
<li>
PHP Sessions</li>
<li>
PHP Sending E-mails</li>
<li>
PHP Secure E-mails</li>
<li>
PHP Error Handling</li>
<li>
PHP Exception Handling</li>
<li>PHP Filter</li>
</ol>
<h3>
PHP With MySQL </h3>
<ol style="text-align: left;">
</ol>
<ol style="text-align: left;">
<li>PHP MySQL Introduction</li>
<li>PHP MySQL Connect to a Database</li>
<li>PHP MySQL Create Database and Tables</li>
<li>PHP MySQL Insert Into</li>
<li>PHP MySQL Select</li>
<li>PHP MySQL The Where Clause</li>
<li>PHP MySQL Order By Keyword</li>
<li>PHP MySQL Update</li>
<li>PHP MySQL Delete</li>
<li>PHP Database ODBC</li>
<li>PHP XML Expat Parser</li>
<li>PHP XML DOM</li>
<li>
PHP Simple XML</li>
</ol>
<h3>
PHP With XML and AJAX</h3>
<ol style="text-align: left;">
<li>AJAX Introduction</li>
<li>AJAX XML HttpRequest</li>
<li>PHP and AJAX Suggest</li>
<li>PHP and AJAX XML Example</li>
<li>PHP and AJAX MySQL Database Example</li>
<li>HP and AJAX response XML Example</li>
<li>PHP and AJAX Live Search</li>
<li>PHP and AJAX RSS Reader</li>
<li>PHP and AJAX Poll </li>
</ol>
<h3>
More Into PHP Functions</h3>
<ol style="text-align: left;">
<li>PHP Array Functions</li>
<li>PHP Calendar Functions</li>
<li>PHP Date / Time Functions</li>
<li>PHP Directory Functions</li>
<li>PHP Error and Logging Functions</li>
<li>PHP Filesystem Functions</li>
<li>PHP Filter Functions</li>
<li>PHP FTP Functions</li>
<li>PHP HTTP Functions</li>
<li>PHP libxml Functions</li>
<li>PHP Mail Functions</li>
<li>PHP Math Functions</li>
<li>PHP Misc. Functions</li>
<li>PHP MySQL Functions</li>
<li>PHP Simple XML Functions</li>
<li>PHP String Functions</li>
<li>PHP XML Parser Functions</li>
<li>PHP Zip File Functions</li>
</ol>
</div>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-357226456970214079.post-61924990971271641012023-07-29T10:23:00.010+05:302023-07-29T10:23:26.400+05:30PHP28-PHP Directory Functions<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiX9Eni09sb6oBBszBimPN1MRetEDDsjvj4UIX-AO_4Wj3uLETzT6uOF5xBtcjPTbu1zEZenXV4CioTWdxhCC9XkEdo0y8TsiMLXMi48e0q2zRbPUBhNvRrEUoRhHczaiiJQSpfezFUjDk/s1600/intro.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="489" data-original-width="870" height="179" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiX9Eni09sb6oBBszBimPN1MRetEDDsjvj4UIX-AO_4Wj3uLETzT6uOF5xBtcjPTbu1zEZenXV4CioTWdxhCC9XkEdo0y8TsiMLXMi48e0q2zRbPUBhNvRrEUoRhHczaiiJQSpfezFUjDk/s320/intro.jpg" width="320" /></a></div>
<h3>
PHP Directory Introduction</h3>
The directory functions allow you to retrieve information about directories
and their contents.<br />
<hr />
<h3>
Installation</h3>
The directory functions are part of the PHP core. There is no installation
needed to use these functions.<br />
<hr />
<h3>
PHP Directory Functions</h3>
<b>PHP</b>: indicates the earliest version of PHP that supports the
function. <br />
<table border="1" cellspacing="0" class="ex" id="table4" style="width: 100%px;">
<tbody>
<tr>
<th align="left" valign="top" width="38%">Function</th>
<th align="left" valign="top" width="57%">Description</th>
<th align="left" valign="top" width="5%">PHP</th>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">chdir()</a></td>
<td valign="top">Changes the current directory</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">chroot()</a></td>
<td valign="top">Changes the root directory of the current process</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">dir()</a></td>
<td valign="top">Opens a directory handle and returns an object</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">closedir()</a></td>
<td valign="top">Closes a directory handle</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">getcwd()</a></td>
<td valign="top">Returns the current directory</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">opendir()</a></td>
<td valign="top">Opens a directory handle</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">readdir()</a></td>
<td valign="top">Returns an entry from a directory handle</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">rewinddir()</a></td>
<td valign="top">Resets a directory handle</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">scandir()</a></td>
<td valign="top">Lists files and directories inside a specified path</td>
<td valign="top">5</td>
</tr>
</tbody></table>
<br />
<hr />
<h3>
PHP Directory Constants</h3>
<b>PHP</b>: indicates the earliest version of PHP that supports the
constant.<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table5" style="width: 100%px;">
<tbody>
<tr>
<th align="left" width="38%">Constant</th>
<th align="left" width="57%">Description</th>
<th align="left" width="5%">PHP</th>
</tr>
<tr>
<td valign="top">DIRECTORY_SEPARATOR</td>
<td valign="top"></td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top">PATH_SEPARATOR</td>
<td valign="top"></td>
<td valign="top">4</td>
</tr>
</tbody></table>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-357226456970214079.post-65043041528211992042023-07-29T10:23:00.009+05:302023-07-29T10:23:20.496+05:30PHP31-PHP Filter Functions<h3>
PHP Filter Introduction</h3>
This PHP filters is used to validate and filter data coming from insecure sources,
like user input.<br />
<hr />
<h3>
Installation</h3>
The filter functions are part of the PHP core. There is no installation needed
to use these functions.<br />
<hr />
<h3>
PHP Filter Functions</h3>
<b>PHP</b>: indicates the earliest version of PHP that supports the
function.<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table4" style="width: 100%px;">
<tbody>
<tr>
<th align="left" valign="top" width="30%">Function</th>
<th align="left" valign="top" width="65%">Description</th>
<th align="left" valign="top" width="5%">PHP</th>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">filter_has_var()</a></td>
<td valign="top">Checks if a variable of a specified input type exist</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">filter_id()</a></td>
<td valign="top">Returns the ID number of a specified filter</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">filter_input()</a></td>
<td valign="top">Get input from outside the script and filter it</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">filter_input_array()</a></td>
<td valign="top">Get multiple inputs from outside the script and filters
them</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">filter_list()</a></td>
<td valign="top">Returns an array of all supported filters</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">filter_var_array()</a></td>
<td valign="top">Get multiple variables and filter them</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">filter_var()</a></td>
<td valign="top">Get a variable and filter it</td>
<td valign="top">5</td>
</tr>
</tbody></table>
<br />
<hr />
<h3>
PHP Filters</h3>
<table border="1" cellspacing="0" class="ex" style="width: 100%px;">
<tbody>
<tr>
<th align="left" valign="top" width="50%">ID Name</th>
<th align="left" valign="top" width="50%">Description</th>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">FILTER_CALLBACK</a></td>
<td valign="top">Call a user-defined function to filter data</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">FILTER_SANITIZE_STRING</a></td>
<td valign="top">Strip tags, optionally strip or encode special characters</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">FILTER_SANITIZE_STRIPPED</a></td>
<td valign="top">Alias of "string" filter</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">FILTER_SANITIZE_ENCODED</a></td>
<td valign="top">URL-encode string, optionally strip or encode special
characters</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">FILTER_SANITIZE_SPECIAL_CHARS</a></td>
<td valign="top">HTML-escape '"<>& and characters with ASCII value less than
32</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">FILTER_SANITIZE_EMAIL</a></td>
<td valign="top">Remove all characters, except letters, digits and !#$%&'*+-/=?^_`{|}~@.[]</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">FILTER_SANITIZE_URL</a></td>
<td valign="top">Remove all characters, except letters, digits and $-_.+!*'(),{}|\\^~[]`<>#%";/?:@&=</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">FILTER_SANITIZE_NUMBER_INT</a></td>
<td valign="top">Remove all characters, except digits and +-</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">FILTER_SANITIZE_NUMBER_FLOAT</a></td>
<td valign="top">Remove all characters, except digits, +- and optionally .,eE</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">FILTER_SANITIZE_MAGIC_QUOTES</a></td>
<td valign="top">Apply addslashes()</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">FILTER_UNSAFE_RAW</a></td>
<td valign="top">Do nothing, optionally strip or encode special characters</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">FILTER_VALIDATE_INT</a></td>
<td valign="top">Validate value as integer, optionally from the specified
range</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">FILTER_VALIDATE_BOOLEAN</a></td>
<td valign="top">Return TRUE for "1", "true", "on" and "yes", FALSE for "0",
"false", "off", "no", and "", NULL otherwise</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">FILTER_VALIDATE_FLOAT</a></td>
<td valign="top">Validate value as float</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">FILTER_VALIDATE_REGEXP</a></td>
<td valign="top">Validate value against regexp, a Perl-compatible regular
expression</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">FILTER_VALIDATE_URL</a></td>
<td valign="top">Validate value as URL, optionally with required components</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">FILTER_VALIDATE_EMAIL</a></td>
<td valign="top">Validate value as e-mail</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">FILTER_VALIDATE_IP</a></td>
<td valign="top">Validate value as IP address, optionally only IPv4 or IPv6
or not from private or reserved ranges</td>
</tr>
</tbody></table>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-357226456970214079.post-69014556957883281252023-07-29T10:23:00.008+05:302023-07-29T10:23:18.823+05:30PHP42-PHP Zip File FunctionsThe Zip files functions allows you to read ZIP files.<br />
<h3>
Installation</h3>
For the Zip file functions to work on your server, these libraries must be
installed:<br />
<ul>
<li>The ZZIPlib library by Guido Draheim:
Download the ZZIPlib
library</li>
<li>The Zip PELC extension: Download the Zip
PELC extension</li>
</ul>
<b>Installation on Linux Systems</b><br />
<br />
<b>PHP 5+:</b> Zip functions and the Zip library is not enabled by default
and must be downloaded from the links above. Use the
<i>--with-zip=DIR</i> configure option to include Zip support.<br />
<br />
<b>Installation on Windows Systems</b><br />
<br />
<b>PHP 5+:</b> Zip functions is not enabled by default, so the php_zip.dll
and the ZZIPlib library must be downloaded from the link above. php_zip.dll must
be enabled inside of php.ini. <br />
To enable any PHP extension, the PHP extension_dir setting (in the php.ini
file) should be set to the directory where the PHP extensions are
located. An example extension_dir value is c:\php\ext.<br />
<hr />
<h3>
PHP Zip File Functions</h3>
<b>PHP</b>: indicates the earliest version of PHP that supports the
function.<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table4" style="width: 100%px;">
<tbody>
<tr>
<th align="left" valign="top" width="40%">Function</th>
<th align="left" valign="top" width="55%">Description</th>
<th align="left" valign="top" width="5%">PHP</th>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">zip_close()</a></td>
<td valign="top">Closes a ZIP file</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">zip_entry_close()</a></td>
<td valign="top">Closes an entry in the ZIP file</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">zip_entry_compressedsize()</a></td>
<td valign="top">Returns the compressed size of an entry in the ZIP file</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">zip_entry_compressionmethod()</a></td>
<td valign="top">Returns the compression method of an entry in the ZIP file</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">zip_entry_filesize()</a></td>
<td valign="top">Returns the actual file size of an entry in the ZIP file</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">zip_entry_name()</a></td>
<td valign="top">Returns the name of an entry in the ZIP file</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">zip_entry_open()</a></td>
<td valign="top">Opens an entry in the ZIP file for reading</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">zip_entry_read()</a></td>
<td valign="top">Reads from an open entry in the ZIP file</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">zip_open()</a></td>
<td valign="top">Opens a ZIP file</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">zip_read()</a></td>
<td valign="top">Reads the next entry in a ZIP file</td>
<td valign="top">4</td>
</tr>
</tbody></table>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-357226456970214079.post-57225252676260868712023-07-29T10:23:00.007+05:302023-07-29T10:23:16.884+05:30PHP41-PHP XML Parser Functions<h3>
PHP XML Parser Introduction</h3>
The XML functions lets you parse, but not validate, XML documents.<br />
<div style="text-align: justify;">
XML is a data format for standardized structured document exchange. More
information on XML can be found in our
<a href="http://www.blogger.com/blogger.g?blogID=357226456970214079" target="_blank">XML Tutorial</a>.</div>
This extension uses the Expat XML parser.<br />
<div style="text-align: justify;">
Expat is an event-based parser, it views an XML document as a series of
events. When an event occurs, it calls a specified function to handle it.</div>
<div style="text-align: justify;">
Expat is a non-validating parser, and ignores any DTDs linked to a document.
However, if the document is not well formed it will end with an error message.</div>
<div style="text-align: justify;">
Because it is an event-based, non validating parser, Expat is fast and well
suited for web applications.</div>
<div style="text-align: justify;">
The XML parser functions lets you create XML parsers and define handlers for XML
events.</div>
<hr />
<h3>
Installation</h3>
The XML functions are part of the PHP core. There is no installation
needed to use these functions.<br />
<hr />
<h3>
PHP XML Parser Functions</h3>
<b>PHP</b>: indicates the earliest version of PHP that supports the
function.<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table4" style="width: 100%px;">
<tbody>
<tr>
<th align="left" valign="top" width="55%">Function</th>
<th align="left" valign="top" width="45%">Description</th>
<th align="left" valign="top" width="5%">PHP</th>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">utf8_decode()</a></td>
<td valign="top">Decodes an UTF-8 string to ISO-8859-1</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">utf8_encode()</a></td>
<td valign="top">Encodes an ISO-8859-1 string to UTF-8</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">xml_error_string()</a></td>
<td valign="top">Gets an error string from the XML parser</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">xml_get_current_byte_index()</a></td>
<td valign="top">Gets the current byte index from the XML parser</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">xml_get_current_column_number()</a></td>
<td valign="top">Gets the current column number from the XML parser</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">xml_get_current_line_number()</a></td>
<td valign="top">Gets the current line number from the XML parser</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">xml_get_error_code()</a></td>
<td valign="top">Gets an error code from the XML parser</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">xml_parse()</a></td>
<td valign="top">Parses an XML document</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">xml_parse_into_struct()</a></td>
<td valign="top">Parse XML data into an array</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">xml_parser_create_ns()</a></td>
<td valign="top">Create an XML parser with namespace support</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">xml_parser_create()</a></td>
<td valign="top">Create an XML parser</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">xml_parser_free()</a></td>
<td valign="top">Free an XML parser</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">xml_parser_get_option()</a></td>
<td valign="top">Get options from an XML parser</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">xml_parser_set_option()</a></td>
<td valign="top">Set options in an XML parser</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">xml_set_character_data_handler()</a></td>
<td valign="top">Set handler function for character data</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">xml_set_default_handler()</a></td>
<td valign="top">Set default handler function</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">xml_set_element_handler()</a></td>
<td valign="top">Set handler function for start and end element of elements</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top">xml_set_end_namespace_decl_handler()</td>
<td valign="top">Set handler function for the end of namespace declarations</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">xml_set_external_entity_ref_handler()</a></td>
<td valign="top">Set handler function for external entities</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">xml_set_notation_decl_handler()</a></td>
<td valign="top">Set handler function for notation declarations</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">xml_set_object()</a></td>
<td valign="top">Use XML Parser within an object</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">xml_set_processing_instruction_handler()</a></td>
<td valign="top">Set handler function for processing instruction</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top">xml_set_start_namespace_decl_handler()</td>
<td valign="top">Set handler function for the start of namespace
declarations</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">xml_set_unparsed_entity_decl_handler()</a></td>
<td valign="top">Set handler function for unparsed entity declarations</td>
<td valign="top">3</td>
</tr>
</tbody></table>
<br />
<hr />
<h3>
PHP XML Parser Constants</h3>
<table border="1" cellspacing="0" class="ex" id="table5" style="width: 100%px;">
<tbody>
<tr>
<th align="left" width="30%">Constant</th>
</tr>
<tr>
<td valign="top">XML_ERROR_NONE (integer)</td>
</tr>
<tr>
<td valign="top">XML_ERROR_NO_MEMORY (integer)</td>
</tr>
<tr>
<td valign="top">XML_ERROR_SYNTAX (integer)</td>
</tr>
<tr>
<td valign="top">XML_ERROR_NO_ELEMENTS (integer)</td>
</tr>
<tr>
<td valign="top">XML_ERROR_INVALID_TOKEN (integer)</td>
</tr>
<tr>
<td valign="top">XML_ERROR_UNCLOSED_TOKEN (integer)</td>
</tr>
<tr>
<td valign="top">XML_ERROR_PARTIAL_CHAR (integer)</td>
</tr>
<tr>
<td valign="top">XML_ERROR_TAG_MISMATCH (integer)</td>
</tr>
<tr>
<td valign="top">XML_ERROR_DUPLICATE_ATTRIBUTE (integer)</td>
</tr>
<tr>
<td valign="top">XML_ERROR_JUNK_AFTER_DOC_ELEMENT (integer)</td>
</tr>
<tr>
<td valign="top">XML_ERROR_PARAM_ENTITY_REF (integer)</td>
</tr>
<tr>
<td valign="top">XML_ERROR_UNDEFINED_ENTITY (integer)</td>
</tr>
<tr>
<td valign="top">XML_ERROR_RECURSIVE_ENTITY_REF (integer)</td>
</tr>
<tr>
<td valign="top">XML_ERROR_ASYNC_ENTITY (integer)</td>
</tr>
<tr>
<td valign="top">XML_ERROR_BAD_CHAR_REF (integer)</td>
</tr>
<tr>
<td valign="top">XML_ERROR_BINARY_ENTITY_REF (integer)</td>
</tr>
<tr>
<td valign="top">XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF (integer)</td>
</tr>
<tr>
<td valign="top">XML_ERROR_MISPLACED_XML_PI (integer)</td>
</tr>
<tr>
<td valign="top">XML_ERROR_UNKNOWN_ENCODING (integer)</td>
</tr>
<tr>
<td valign="top">XML_ERROR_INCORRECT_ENCODING (integer)</td>
</tr>
<tr>
<td valign="top">XML_ERROR_UNCLOSED_CDATA_SECTION (integer)</td>
</tr>
<tr>
<td valign="top">XML_ERROR_EXTERNAL_ENTITY_HANDLING (integer)</td>
</tr>
<tr>
<td valign="top">XML_OPTION_CASE_FOLDING (integer)</td>
</tr>
<tr>
<td valign="top">XML_OPTION_TARGET_ENCODING (integer)</td>
</tr>
<tr>
<td valign="top">XML_OPTION_SKIP_TAGSTART (integer)</td>
</tr>
<tr>
<td valign="top">XML_OPTION_SKIP_WHITE (integer)</td>
</tr>
</tbody></table>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-357226456970214079.post-27959700751157962022023-07-29T10:23:00.006+05:302023-07-29T10:23:15.060+05:30PHP40-PHP String Functions<h3>
PHP String Introduction</h3>
The string functions allow you to manipulate strings.<br />
<hr />
<h3>
Installation</h3>
The string functions are part of the PHP core. There is no installation
needed to use these functions.<br />
<hr />
<h3>
PHP String Functions</h3>
<b>PHP</b>: indicates the earliest version of PHP that supports the
function.<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table4" style="width: 100%px;">
<tbody>
<tr>
<th align="left" valign="top" width="38%">Function</th>
<th align="left" valign="top" width="57%">Description</th>
<th align="left" valign="top" width="5%">PHP</th>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">addcslashes()</a></td>
<td valign="top">Returns a string with backslashes in front of the specified
characters</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">addslashes()</a></td>
<td valign="top">Returns a string with backslashes in front of predefined
characters</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">bin2hex()</a></td>
<td valign="top">Converts a string of ASCII characters to hexadecimal values</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">chop()</a></td>
<td valign="top">Alias of rtrim()</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">chr()</a></td>
<td valign="top">Returns a character from a specified ASCII value</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">chunk_split()</a></td>
<td valign="top">Splits a string into a series of smaller parts</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">convert_cyr_string()</a></td>
<td valign="top">Converts a string from one Cyrillic character-set to another</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">convert_uudecode()</a></td>
<td valign="top">Decodes a uuencoded string</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">convert_uuencode()</a></td>
<td valign="top">Encodes a string using the uuencode algorithm</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">count_chars()</a></td>
<td valign="top">Returns how many times an ASCII character occurs within a
string and returns the information</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">crc32()</a></td>
<td valign="top">Calculates a 32-bit CRC for a string</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">crypt()</a></td>
<td valign="top">One-way string encryption (hashing)</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">echo()</a></td>
<td valign="top">Outputs strings</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">explode()</a></td>
<td valign="top">Breaks a string into an array</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">fprintf()</a></td>
<td valign="top">Writes a formatted string to a specified output stream</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">get_html_translation_table()</a></td>
<td valign="top">Returns the translation table used by htmlspecialchars()
and htmlentities()</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">hebrev()</a></td>
<td valign="top">Converts Hebrew text to visual text</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">hebrevc()</a></td>
<td valign="top">Converts Hebrew text to visual text and new lines (\n) into
<br /></td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">html_entity_decode()</a></td>
<td valign="top">Converts HTML entities to characters</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">htmlentities()</a></td>
<td valign="top">Converts characters to HTML entities</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">htmlspecialchars_decode()</a></td>
<td valign="top">Converts some predefined HTML entities to characters</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">htmlspecialchars()</a></td>
<td valign="top">Converts some predefined characters to HTML entities</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">implode()</a></td>
<td valign="top">Returns a string from the elements of an array</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">join()</a></td>
<td valign="top">Alias of implode()</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">levenshtein()</a></td>
<td valign="top">Returns the Levenshtein distance between two strings</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">localeconv()</a></td>
<td valign="top">Returns locale numeric and monetary formatting information</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">ltrim()</a></td>
<td valign="top">Strips whitespace from the left side of a string</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">md5()</a></td>
<td valign="top">Calculates the MD5 hash of a string</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">md5_file()</a></td>
<td valign="top">Calculates the MD5 hash of a file</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">metaphone()</a></td>
<td valign="top">Calculates the metaphone key of a string</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">money_format()</a></td>
<td valign="top">Returns a string formatted as a currency string</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">nl_langinfo()</a></td>
<td valign="top">Returns specific local information</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">nl2br()</a></td>
<td valign="top">Inserts HTML line breaks in front
of each newline in a string</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">number_format()</a></td>
<td valign="top">Formats a number with grouped thousands</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">ord()</a></td>
<td valign="top">Returns the ASCII value of the first character of a string</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">parse_str()</a></td>
<td valign="top">Parses a query string into variables</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">print()</a></td>
<td valign="top">Outputs a string</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">printf()</a></td>
<td valign="top">Outputs a formatted string</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">quoted_printable_decode()</a></td>
<td valign="top">Decodes a quoted-printable string</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">quotemeta()</a></td>
<td valign="top">Quotes meta characters</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">rtrim()</a></td>
<td valign="top">Strips whitespace from the right side of a string</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">setlocale()</a></td>
<td valign="top">Sets locale information</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">sha1()</a></td>
<td valign="top">Calculates the SHA-1 hash of a string</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">sha1_file()</a></td>
<td valign="top">Calculates the SHA-1 hash of a file</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">similar_text()</a></td>
<td valign="top">Calculates the similarity between two strings</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">soundex()</a></td>
<td valign="top">Calculates the soundex key of a string</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">sprintf()</a></td>
<td valign="top">Writes a formatted string to a variable</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">sscanf()</a></td>
<td valign="top">Parses input from a string according to a format</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">str_ireplace()</a></td>
<td valign="top">Replaces some characters in a
string (case-insensitive)</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">str_pad()</a></td>
<td valign="top">Pads a string to a new length</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">str_repeat()</a></td>
<td valign="top">Repeats a string a specified number of times</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">str_replace()</a></td>
<td valign="top">Replaces some characters in a
string (case-sensitive)</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">str_rot13()</a></td>
<td valign="top">Performs the ROT13 encoding on a string</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">str_shuffle()</a></td>
<td valign="top">Randomly shuffles all characters in a string</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">str_split()</a></td>
<td valign="top">Splits a string into an array</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">str_word_count()</a></td>
<td valign="top">Count the number of words in a string</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">strcasecmp()</a></td>
<td valign="top">Compares two strings (case-insensitive)</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">strchr()</a></td>
<td valign="top">Finds the first occurrence of a string inside another
string (alias of strstr())</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">strcmp()</a></td>
<td valign="top">Compares two strings (case-sensitive)</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">strcoll()</a></td>
<td valign="top">Locale based string comparison</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">strcspn()</a></td>
<td valign="top">Returns the number of characters found in a string before
any part of some specified characters are found</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">strip_tags()</a></td>
<td valign="top">Strips HTML and PHP tags from a string</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">stripcslashes()</a></td>
<td valign="top">Unquotes a string quoted with addcslashes()</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">stripslashes()</a></td>
<td valign="top">Unquotes a string quoted with addslashes()</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">stripos()</a></td>
<td valign="top">Returns the position of the first occurrence of a string
inside another string (case-insensitive)</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">stristr()</a></td>
<td valign="top">Finds the first occurrence of a string inside another
string (case-insensitive)</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">strlen()</a></td>
<td valign="top">Returns the length of a string</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">strnatcasecmp()</a></td>
<td valign="top">Compares two strings using a "natural order"
algorithm (case-insensitive)</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">strnatcmp()</a></td>
<td valign="top">Compares two strings using a "natural order"
algorithm (case-sensitive)</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">strncasecmp()</a></td>
<td valign="top">String comparison of the first
n characters (case-insensitive)</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">strncmp()</a></td>
<td valign="top">String comparison of the first
n characters (case-sensitive)</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">strpbrk()</a></td>
<td valign="top">Searches a string for any of a set of characters</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">strpos()</a></td>
<td valign="top">Returns the position of the first occurrence of a string
inside another string (case-sensitive)</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">strrchr()</a></td>
<td valign="top">Finds the last occurrence of a string inside another
string</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">strrev()</a></td>
<td valign="top">Reverses a string</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">strripos()</a></td>
<td valign="top">Finds the position of the last occurrence of a
string inside another string (case-insensitive)</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">strrpos()</a></td>
<td valign="top">Finds the position of the last occurrence of a
string inside another string (case-sensitive)</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">strspn()</a></td>
<td valign="top">Returns the number of characters found in a string that
contains only characters from a specified charlist</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">strstr()</a></td>
<td valign="top">Finds the first occurrence of a string inside another
string (case-sensitive)</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">strtok()</a></td>
<td valign="top">Splits a string into smaller strings</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">strtolower()</a></td>
<td valign="top">Converts a string to lowercase letters</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">strtoupper()</a></td>
<td valign="top">Converts a string to uppercase letters</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">strtr()</a></td>
<td valign="top">Translates certain characters in a string</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">substr()</a></td>
<td valign="top">Returns a part of a string</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">substr_compare()</a></td>
<td valign="top">Compares two strings from a specified start position (binary safe
and optionally case-sensitive)</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">substr_count()</a></td>
<td valign="top">Counts the number of times a substring occurs in a string</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">substr_replace()</a></td>
<td valign="top">Replaces a part of a string with another string</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">trim()</a></td>
<td valign="top">Strips whitespace from both sides of a
string</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">ucfirst()</a></td>
<td valign="top">Converts the first character of a string to uppercase</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">ucwords()</a></td>
<td valign="top">Converts the first character of each word in a string to uppercase</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">vfprintf()</a></td>
<td valign="top">Writes a formatted string to a specified output stream</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">vprintf()</a></td>
<td valign="top">Outputs a formatted string</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">vsprintf()</a></td>
<td valign="top">Writes a formatted string to a variable</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">wordwrap()</a></td>
<td valign="top">Wraps a string to a given number of characters</td>
<td valign="top">4</td>
</tr>
</tbody></table>
<br />
<hr />
<h3>
PHP String Constants</h3>
<b>PHP</b>: indicates the earliest version of PHP that supports the
constant.<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table5" style="width: 100%px;">
<tbody>
<tr>
<th align="left" width="38%">Constant</th>
<th align="left" width="57%">Description</th>
<th align="left" width="5%">PHP</th>
</tr>
<tr>
<td valign="top">CRYPT_SALT_LENGTH</td>
<td valign="top">Contains the length of the default encryption method for
the<br />
system. For standard DES encryption, the length is 2</td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">CRYPT_STD_DES</td>
<td valign="top">Set to 1 if the standard DES-based encryption with a 2
character salt is supported, 0 otherwise</td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">CRYPT_EXT_DES</td>
<td valign="top">Set to 1 if the extended DES-based encryption with a 9
character salt is supported, 0 otherwise</td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">CRYPT_MD5</td>
<td valign="top">Set to 1 if the MD5 encryption with a 12 character salt
starting with $1$ is supported, 0 otherwise</td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">CRYPT_BLOWFISH</td>
<td valign="top">Set to 1 if the Blowfish encryption with a 16 character
salt starting with $2$ or $2a$ is supported, 0 otherwise0</td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">HTML_SPECIALCHARS</td>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">HTML_ENTITIES</td>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">ENT_COMPAT</td>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">ENT_QUOTES</td>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">ENT_NOQUOTES</td>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">CHAR_MAX</td>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">LC_CTYPE</td>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">LC_NUMERIC</td>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">LC_TIME</td>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">LC_COLLATE</td>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">LC_MONETARY</td>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">LC_ALL</td>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">LC_MESSAGES</td>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">STR_PAD_LEFT</td>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">STR_PAD_RIGHT</td>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">STR_PAD_BOTH</td>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
</tbody></table>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-357226456970214079.post-63396250523614702532023-07-29T10:23:00.005+05:302023-07-29T10:23:12.604+05:30PHP39-PHP SimpleXML Functions<h3>
PHP SimpleXML Introduction</h3>
The SimpleXML functions lets you convert XML to an object.<br />
This object can be processed, like any other object, with normal property
selectors and array iterators.<br />
Some of these functions requires the newest PHP build.<br />
<hr />
<h3>
Installation</h3>
The SimpleXML functions are part of the PHP core. There is no installation
needed to use these functions.<br />
<hr />
<h3>
PHP SimpleXML Functions</h3>
<b>PHP</b>: indicates the earliest version of PHP that supports the
function.<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table4" style="width: 100%px;">
<tbody>
<tr>
<th align="left" valign="top" width="35%">Function</th>
<th align="left" valign="top" width="60%">Description</th>
<th align="left" valign="top" width="5%">PHP</th>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">__construct()</a></td>
<td valign="top">Creates a new SimpleXMLElement object</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">addAttribute()</a></td>
<td valign="top">Adds an attribute to the SimpleXML element</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">addChild()</a></td>
<td valign="top">Adds a child element the SimpleXML element</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">asXML()</a></td>
<td valign="top">Gets an XML string from a SimpleXML element</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">attributes()</a></td>
<td valign="top">Gets a SimpleXML element's attributes</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">children()</a></td>
<td valign="top">Gets the children of a specified node</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">getDocNamespaces()</a></td>
<td valign="top">Gets the namespaces of an XML document</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">getName()</a></td>
<td valign="top">Gets the name of a SimpleXML element</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">getNamespaces()</a></td>
<td valign="top">Gets the namespaces from XML data</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">registerXPathNamespace()</a></td>
<td valign="top">Creates a namespace context for the next XPath query</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">simplexml_import_dom()</a></td>
<td valign="top">Gets a SimpleXMLElement object from a DOM node</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">simplexml_load_file()</a></td>
<td valign="top">Gets a SimpleXMLElement object from an XML document</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">simplexml_load_string()</a></td>
<td valign="top">Gets a SimpleXMLElement object from an XML string</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">xpath()</a></td>
<td valign="top">Runs an XPath query on XML data</td>
<td valign="top">5</td>
</tr>
</tbody></table>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-357226456970214079.post-51547319966934788642023-07-29T10:23:00.004+05:302023-07-29T10:23:10.649+05:30PHP38-PHP MySQL Functions<h3>
PHP MySQL Introduction</h3>
The MySQL functions allows you to access MySQL database servers.<br />
<hr />
<h3>
Installation</h3>
For the MySQL functions to be available, you must compile PHP with MySQL
support.<br />
For compiling, use <i>--with-mysql=DIR </i>(the optional DIR points to the MySQL directory).<br />
<b>Note:</b> For full functionality of MySQL
versions greater than 4.1., use the MySQLi extension instead. If you would like to install
both the mysql extension and the mysqli extension you should use the same client
library to avoid any conflicts.<br />
<b>Installation on Linux Systems</b><br />
<b>PHP 5+:</b> MySQL and the MySQL library is not enabled by default. Use the
<i>--with-mysql=DIR</i> configure option to include MySQL
support and download headers and libraries from
<a href="http://www.blogger.com/blogger.g?blogID=357226456970214079" target="_blank">www.mysql.com</a>.<br />
<b>Installation on Windows Systems</b><br />
<b>PHP 5+:</b> MySQL is not enabled by default, so the php_mysql.dll must be enabled inside of php.ini. Also, PHP needs access to the MySQL
client library. A file named libmysql.dll is included in the Windows PHP
distribution, and in order for PHP to talk to MySQL this file needs to be
available to the Windows systems PATH.<br />
To enable any PHP extension, the PHP extension_dir setting (in the php.ini
file) should be set to the directory where the PHP extensions are
located. An example extension_dir value is c:\php\ext.<br />
<b>Note:</b> If you get the following error when starting the web
server: "Unable to load dynamic library './php_mysql.dll'", this is
because
php_mysql.dll or libmysql.dll cannot be found by the system.<br />
<hr />
<h3>
Runtime Configuration</h3>
The behavior of the MySQL functions is affected by settings in the php.ini
file.<br />
MySQL configuration options:<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table9" style="width: 100%px;">
<tbody>
<tr>
<th align="left" valign="top" width="20%">Name</th>
<th align="left" valign="top" width="15%">Default</th>
<th align="left" valign="top" width="42%">Description</th>
<th align="left" valign="top" width="23%">Changeable</th>
</tr>
<tr>
<td valign="top">mysql.allow_persistent</td>
<td valign="top">"1"</td>
<td valign="top">Whether or not to allow persistent connections</td>
<td valign="top">PHP_INI_SYSTEM</td>
</tr>
<tr>
<td valign="top">mysql.max_persistent</td>
<td valign="top">"-1"</td>
<td valign="top">The maximum number of persistent connections per
process</td>
<td valign="top">PHP_INI_SYSTEM</td>
</tr>
<tr>
<td valign="top">mysql.max_links</td>
<td valign="top">"-1"</td>
<td valign="top">The maximum number of connections per process
(persistent connections included)</td>
<td valign="top">PHP_INI_SYSTEM</td>
</tr>
<tr>
<td valign="top">mysql.trace_mode</td>
<td valign="top">"0"</td>
<td valign="top">Trace mode. When set to "1", warnings and SQL-errors will be displayed.
Available since PHP 4.3</td>
<td valign="top">PHP_INI_ALL</td>
</tr>
<tr>
<td valign="top">mysql.default_port</td>
<td valign="top">NULL</td>
<td valign="top">The default TCP port number to use</td>
<td valign="top">PHP_INI_ALL</td>
</tr>
<tr>
<td valign="top">mysql.default_socket</td>
<td valign="top">NULL</td>
<td valign="top">The default socket name to use. Available since PHP
4.0.1</td>
<td valign="top">PHP_INI_ALL</td>
</tr>
<tr>
<td valign="top">mysql.default_host</td>
<td valign="top">NULL</td>
<td valign="top">The default server host to use (doesn't apply in SQL safe
mode)</td>
<td valign="top">PHP_INI_ALL</td>
</tr>
<tr>
<td valign="top">mysql.default_user</td>
<td valign="top">NULL</td>
<td valign="top">The default user name to use (doesn't apply in SQL safe
mode)</td>
<td valign="top">PHP_INI_ALL</td>
</tr>
<tr>
<td valign="top">mysql.default_password</td>
<td valign="top">NULL</td>
<td valign="top">The default password to use (doesn't apply in SQL safe mode)</td>
<td valign="top">PHP_INI_ALL</td>
</tr>
<tr>
<td valign="top">mysql.connect_timeout</td>
<td valign="top">"60"</td>
<td valign="top">Connection timeout in seconds</td>
<td valign="top">PHP_INI_ALL</td>
</tr>
</tbody></table>
<br />
<hr />
<h3>
Resource Types</h3>
There are two resource types used in the MySQL extension. The first one is the
link_identifier for a database connection, the second is a resource which holds the
result of a query.<br />
<b>Note:</b> Most MySQL functions accept link_identifier as the last optional
parameter. If it is not provided, the last opened connection is used.<br />
<hr />
<h3>
PHP MySQL Functions</h3>
<b>PHP</b>: indicates the earliest version of PHP that supports the
function.<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table4" style="width: 100%px;">
<tbody>
<tr>
<th align="left" valign="top" width="35%">Function</th>
<th align="left" valign="top" width="60%">Description</th>
<th align="left" valign="top" width="5%">PHP</th>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">mysql_affected_rows()</a></td>
<td valign="top">Returns the number of affected rows in the previous MySQL operation</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top">mysql_change_user()</td>
<td valign="top"><span class="red">Deprecated.</span> Changes the user of the current MySQL
connection</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">
mysql_client_encoding()</a></td>
<td valign="top">Returns the name of the character set for the current
connection</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">mysql_close()</a></td>
<td valign="top">Closes a non-persistent MySQL connection</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">mysql_connect()</a></td>
<td valign="top">Opens a non-persistent MySQL connection</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top">mysql_create_db()</td>
<td valign="top"><span class="red">Deprecated.</span> Creates a new MySQL database. Use mysql_query()
instead</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">mysql_data_seek()</a></td>
<td valign="top">Moves the record pointer</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">mysql_db_name()</a></td>
<td valign="top">Returns a database name from a call to mysql_list_dbs()</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top">mysql_db_query()</td>
<td valign="top"><span class="red">Deprecated.</span> Sends a MySQL query. Use mysql_select_db() and
mysql_query() instead</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top">mysql_drop_db()</td>
<td valign="top"><span class="red">Deprecated.</span> Deletes a MySQL database. Use mysql_query()
instead</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">mysql_errno()</a></td>
<td valign="top">Returns the error number of the last MySQL operation</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">mysql_error()</a></td>
<td valign="top">Returns the error description of the last MySQL operation</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top">mysql_escape_string()</td>
<td valign="top"><span class="red">Deprecated.</span> Escapes a string for use in a mysql_query. Use
mysql_real_escape_string() instead</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">mysql_fetch_array()</a></td>
<td valign="top">Returns a row from a recordset as an associative array
and/or a numeric array</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">mysql_fetch_assoc()</a></td>
<td valign="top">Returns a row from a recordset as an associative array</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">mysql_fetch_field()</a></td>
<td valign="top">Returns column info from a recordset as an
object</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">mysql_fetch_lengths()</a></td>
<td valign="top">Returns the length of the contents of each field in a
result row</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">mysql_fetch_object()</a></td>
<td valign="top">Returns a row from a recordset as an object</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">mysql_fetch_row()</a></td>
<td valign="top">Returns a row from a recordset as a numeric array</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">mysql_field_flags()</a></td>
<td valign="top">Returns the flags associated with a field in a
recordset</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">mysql_field_len()</a></td>
<td valign="top">Returns the maximum length of a field in a recordset</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">mysql_field_name()</a></td>
<td valign="top">Returns the name of a field in a recordset</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">mysql_field_seek()</a></td>
<td valign="top">Moves the result pointer to a specified field</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">mysql_field_table()</a></td>
<td valign="top">Returns the name of the table the specified field is in</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">mysql_field_type()</a></td>
<td valign="top">Returns the type of a field in a recordset</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">mysql_free_result()</a></td>
<td valign="top">Free result memory</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">
mysql_get_client_info()</a></td>
<td valign="top">Returns MySQL client info</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">mysql_get_host_info()</a></td>
<td valign="top">Returns MySQL host info</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">
mysql_get_proto_info()</a></td>
<td valign="top">Returns MySQL protocol info</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">
mysql_get_server_info()</a></td>
<td valign="top">Returns MySQL server info</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">mysql_info()</a></td>
<td valign="top">Returns information about the last query</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">mysql_insert_id()</a></td>
<td valign="top">Returns the AUTO_INCREMENT ID generated from the previous INSERT operation</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">mysql_list_dbs()</a></td>
<td valign="top">Lists available databases on a MySQL server</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top">mysql_list_fields()</td>
<td valign="top"><span class="red">Deprecated.</span> Lists MySQL table fields. Use mysql_query()
instead</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">
mysql_list_processes()</a></td>
<td valign="top">Lists MySQL processes</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top">mysql_list_tables()</td>
<td valign="top"><span class="red">Deprecated.</span> Lists tables in a MySQL database. Use mysql_query()
instead</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">mysql_num_fields()</a></td>
<td valign="top">Returns the number of fields in a recordset</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">mysql_num_rows()</a></td>
<td valign="top">Returns the number of rows in a recordset</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">mysql_pconnect()</a></td>
<td valign="top">Opens a persistent MySQL connection</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">mysql_ping()</a></td>
<td valign="top">Pings a server connection or reconnects if there is no
connection</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">mysql_query()</a></td>
<td valign="top">Executes a query on a MySQL database</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">
mysql_real_escape_string()</a></td>
<td valign="top">Escapes a string for use in SQL
statements</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">mysql_result()</a></td>
<td valign="top">Returns the value of a field in a recordset</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">mysql_select_db()</a></td>
<td valign="top">Sets the active MySQL database</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">mysql_stat()</a></td>
<td valign="top">Returns the current system status of the MySQL server</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top">mysql_tablename()</td>
<td valign="top"><span class="red">Deprecated.</span> Returns the table name of field. Use
mysql_query() instead</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">mysql_thread_id()</a></td>
<td valign="top">Returns the current thread ID</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">
mysql_unbuffered_query()</a></td>
<td valign="top">Executes a query on a MySQL database (without fetching / buffering
the result)</td>
<td valign="top">4</td>
</tr>
</tbody></table>
<br />
<hr />
<h3>
PHP MySQL Constants</h3>
Since PHP 4.3 it has been possible to specify additional flags for the mysql_connect() and mysql_pconnect() functions:<br />
<br />
<b>PHP</b>: indicates the earliest version of PHP that supports the
constant.<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table7" style="width: 100%px;">
<tbody>
<tr>
<th align="left" width="45%">Constant</th>
<th align="left" width="50%">Description</th>
<th align="left" width="5%">PHP</th>
</tr>
<tr>
<td valign="top">MYSQL_CLIENT_COMPRESS</td>
<td valign="top">Use compression protocol</td>
<td valign="top">4.3</td>
</tr>
<tr>
<td height="25" valign="top">MYSQL_CLIENT_IGNORE_SPACE</td>
<td height="25" valign="top">Allow space after function names</td>
<td height="25" valign="top">4.3</td>
</tr>
<tr>
<td valign="top">MYSQL_CLIENT_INTERACTIVE</td>
<td valign="top">Allow interactive timeout seconds
of inactivity before closing the connection</td>
<td valign="top">4.3</td>
</tr>
<tr>
<td valign="top">MYSQL_CLIENT_SSL</td>
<td valign="top">Use SSL encryption (only available with
version 4+ of the MySQL client library)</td>
<td valign="top">4.3</td>
</tr>
</tbody></table>
<br />
The mysql_fetch_array() function uses a constant for the different types of
result arrays. The following constants are defined:<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table8" style="width: 100%px;">
<tbody>
<tr>
<th align="left" width="25%">Constant</th>
<th align="left" width="70%">Description</th>
<th align="left" width="5%">PHP</th>
</tr>
<tr>
<td valign="top">MYSQL_ASSOC</td>
<td valign="top">Columns are returned into the array with the fieldname as
the array index</td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">MYSQL_BOTH</td>
<td valign="top">Columns are returned into the array having both a numerical
index and the fieldname as the array index</td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">MYSQL_NUM</td>
<td valign="top">Columns are returned into the array having a numerical
index (index starts at 0)</td>
<td valign="top"> </td>
</tr>
</tbody></table>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-357226456970214079.post-15027185310087973812023-07-29T10:23:00.003+05:302023-07-29T10:23:08.604+05:30PHP37-PHP Misc. Functions<h3>
PHP Miscellaneous Introduction</h3>
The misc. functions were only placed here because none of the other
categories seemed to fit.<br />
<hr />
<h3>
Installation</h3>
The misc functions are part of the PHP core. There is no installation
needed to use these functions.<br />
<hr />
<h3>
Runtime Configuration</h3>
The behavior of the misc functions is affected by settings in the php.ini
file.<br />
Misc. configuration options:<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table6" style="width: 100%px;">
<tbody>
<tr>
<th align="left" valign="top" width="20%">Name</th>
<th align="left" valign="top" width="15%">Default</th>
<th align="left" valign="top" width="42%">Description</th>
<th align="left" valign="top" width="23%">Changeable</th>
</tr>
<tr>
<td valign="top">ignore_user_abort</td>
<td valign="top">"0"</td>
<td valign="top">FALSE indicates that scripts will be terminated as soon as
they try to output something after a client has aborted their connection</td>
<td valign="top">PHP_INI_ALL</td>
</tr>
<tr>
<td valign="top">highlight.string</td>
<td valign="top">"#DD0000"</td>
<td valign="top">Color for highlighting a string in PHP syntax</td>
<td valign="top">PHP_INI_ALL</td>
</tr>
<tr>
<td valign="top">highlight.comment</td>
<td valign="top">"#FF8000"</td>
<td valign="top">Color for highlighting PHP comments</td>
<td valign="top">PHP_INI_ALL</td>
</tr>
<tr>
<td valign="top">highlight.keyword</td>
<td valign="top">"#007700"</td>
<td valign="top">Color for syntax highlighting PHP keywords (e.g.
parenthesis and semicolon) </td>
<td valign="top">PHP_INI_ALL</td>
</tr>
<tr>
<td valign="top">highlight.bg</td>
<td valign="top">"#FFFFFF"</td>
<td valign="top">Color for background</td>
<td valign="top">PHP_INI_ALL</td>
</tr>
<tr>
<td valign="top">highlight.default</td>
<td valign="top">"#0000BB"</td>
<td valign="top">Default color for PHP syntax</td>
<td valign="top">PHP_INI_ALL</td>
</tr>
<tr>
<td valign="top">highlight.html</td>
<td valign="top">"#000000"</td>
<td valign="top">Color for HTML code</td>
<td valign="top">PHP_INI_ALL</td>
</tr>
<tr>
<td valign="top">browscap</td>
<td valign="top">NULL</td>
<td valign="top">Name and location of browser-capabilities file (e.g.
browscap.ini) </td>
<td valign="top">PHP_INI_SYSTEM</td>
</tr>
</tbody></table>
<br />
<hr />
<h3>
PHP Misc. Functions</h3>
<b>PHP</b>: indicates the earliest version of PHP that supports the
function.<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table4" style="width: 100%px;">
<tbody>
<tr>
<th align="left" valign="top" width="30%">Function</th>
<th align="left" valign="top" width="65%">Description</th>
<th align="left" valign="top" width="5%">PHP</th>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">
connection_aborted()</a></td>
<td valign="top">Checks whether the client has disconnected</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">
connection_status()</a></td>
<td valign="top">Returns the current connection status</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top">connection_timeout()</td>
<td valign="top">Deprecated in PHP 4.0.5</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">constant()</a></td>
<td valign="top">Returns the value of a constant</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">define()</a></td>
<td valign="top">Defines a constant</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">defined()</a></td>
<td valign="top">Checks whether a constant exists</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">die()</a></td>
<td valign="top">Prints a message and exits the current script</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">eval()</a></td>
<td valign="top">Evaluates a string as PHP code</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">exit()</a></td>
<td valign="top">Prints a message and exits the current script</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">get_browser()</a></td>
<td valign="top">Returns the capabilities of the user's browser </td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">highlight_file()</a></td>
<td valign="top">Outputs a file with the PHP syntax highlighted</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">highlight_string()</a></td>
<td valign="top">Outputs a string with the PHP syntax highlighted</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">
ignore_user_abort()</a></td>
<td valign="top">Sets whether a remote client can abort the running of a
script</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">pack()</a></td>
<td valign="top">Packs data into a binary string</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top">php_check_syntax()</td>
<td valign="top">Deprecated in PHP 5.0.5</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">
php_strip_whitespace()</a></td>
<td valign="top">Returns the source code of a file with PHP comments and whitespace
removed</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">show_source()</a></td>
<td valign="top">Alias of highlight_file()</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">sleep()</a></td>
<td valign="top">Delays code execution for a number of seconds</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">time_nanosleep()</a></td>
<td valign="top">Delays code execution for a number of seconds and nanoseconds</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">time_sleep_until()</a></td>
<td valign="top">Delays code execution until a specified time</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">uniqid()</a></td>
<td valign="top">Generates a unique ID</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">unpack()</a></td>
<td valign="top">Unpacks data from a binary string</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">usleep()</a></td>
<td valign="top">Delays code execution for a number of microseconds</td>
<td valign="top">3</td>
</tr>
</tbody></table>
<br />
<hr />
<h3>
PHP Misc. Constants</h3>
<b>PHP</b>: indicates the earliest version of PHP that supports the
constant.<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table5" style="width: 100%px;">
<tbody>
<tr>
<th align="left" width="30%">Constant</th>
<th align="left" width="65%">Description</th>
<th align="left" width="5%">PHP</th>
</tr>
<tr>
<td valign="top">CONNECTION_ABORTED</td>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">CONNECTION_NORMAL</td>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">CONNECTION_TIMEOUT</td>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">__COMPILER_HALT_OFFSET__</td>
<td valign="top"> </td>
<td valign="top">5</td>
</tr>
</tbody></table>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-357226456970214079.post-52850677882711855692023-07-29T10:23:00.002+05:302023-07-29T10:23:06.058+05:30PHP36-PHP Math Functions<h3>
PHP Math Introduction</h3>
The math functions can handle values within the range of integer and float
types.<br />
<hr />
<h3>
Installation</h3>
The math functions are part of the PHP core. There is no installation
needed to use these functions.<br />
<hr />
<h3>
PHP Math Functions</h3>
<b>PHP</b>: indicates the earliest version of PHP that supports the
function.<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table4" style="width: 100%px;">
<tbody>
<tr>
<th align="left" valign="top" width="30%">Function</th>
<th align="left" valign="top" width="65%">Description</th>
<th align="left" valign="top" width="5%">PHP</th>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">abs()</a></td>
<td valign="top">Returns the absolute value of a number</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">acos()</a></td>
<td valign="top">Returns the arccosine of a number</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">acosh()</a></td>
<td valign="top">Returns the inverse hyperbolic cosine of a number </td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">asin()</a></td>
<td valign="top">Returns the arcsine of a number</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">asinh()</a></td>
<td valign="top">Returns the inverse hyperbolic sine of a number</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">atan()</a></td>
<td valign="top">Returns the arctangent of a number as a numeric value between
-PI/2 and PI/2 radians</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">atan2()</a></td>
<td valign="top">Returns the angle theta of an (x,y) point as a numeric
value between -PI and PI radians</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">atanh()</a></td>
<td valign="top">Returns the inverse hyperbolic tangent of a number</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">base_convert()</a></td>
<td valign="top">Converts a number from one base to another</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">bindec()</a></td>
<td valign="top">Converts a binary number to a decimal number</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">ceil()</a></td>
<td valign="top">Returns the value of a number rounded upwards to the
nearest integer</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">cos()</a></td>
<td valign="top">Returns the cosine of a number</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">cosh()</a></td>
<td valign="top">Returns the hyperbolic cosine of a number</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">decbin()</a></td>
<td valign="top">Converts a decimal number to a binary number</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">dechex()</a></td>
<td valign="top">Converts a decimal number to a hexadecimal number</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">decoct()</a></td>
<td valign="top">Converts a decimal number to an octal number</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">deg2rad()</a></td>
<td valign="top">Converts a degree to a radian number</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">exp()</a></td>
<td valign="top">Returns the value of E<sup>x</sup></td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">expm1()</a></td>
<td valign="top">Returns the value of E<sup>x</sup> - 1</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">floor()</a></td>
<td valign="top">Returns the value of a number rounded downwards to the
nearest integer</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">fmod()</a></td>
<td valign="top">Returns the remainder (modulo) of the division of the
arguments</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top">
<div align="left">
<a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">getrandmax()</a></div>
</td>
<td valign="top">Returns the maximum random number that can be returned by
a call to the rand() function</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">hexdec()</a></td>
<td valign="top">Converts a hexadecimal number to a decimal number</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">hypot()</a></td>
<td valign="top">Returns the length of the hypotenuse of a right-angle
triangle</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">is_finite()</a></td>
<td valign="top">Returns true if a value is a finite number</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">is_infinite()</a></td>
<td valign="top">Returns true if a value is an infinite number</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">is_nan()</a></td>
<td valign="top">Returns true if a value is not a number</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">lcg_value()</a></td>
<td valign="top">Returns a pseudo random number in the range of (0,1)</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">log()</a></td>
<td valign="top">Returns the natural logarithm (base E) of a number</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">log10()</a></td>
<td valign="top">Returns the base-10 logarithm of a number</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">log1p()</a></td>
<td valign="top">Returns log(1+number)</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">max()</a></td>
<td valign="top">Returns the number with the highest value of two specified
numbers</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">min()</a></td>
<td valign="top">Returns the number with the lowest value of two specified
numbers</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">mt_getrandmax()</a></td>
<td valign="top">Returns the largest possible value that can be returned by
mt_rand()</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">mt_rand()</a></td>
<td valign="top">Returns a random integer using Mersenne Twister algorithm</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">mt_srand()</a></td>
<td valign="top">Seeds the Mersenne Twister random number generator</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">octdec()</a></td>
<td valign="top">Converts an octal number to a decimal number</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">pi()</a></td>
<td valign="top">Returns the value of PI</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">pow()</a></td>
<td valign="top">Returns the value of x to the power of y</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">rad2deg()</a></td>
<td valign="top">Converts a radian number to a degree</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">rand()</a></td>
<td valign="top">Returns a random integer</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">round()</a></td>
<td valign="top">Rounds a number to the nearest integer</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">sin()</a></td>
<td valign="top">Returns the sine of a number</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">sinh()</a></td>
<td valign="top">Returns the hyperbolic sine of a number</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">sqrt()</a></td>
<td valign="top">Returns the square root of a number</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">srand()</a></td>
<td valign="top">Seeds the random number generator</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">tan()</a></td>
<td valign="top">Returns the tangent of an angle</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">tanh()</a></td>
<td valign="top">Returns the hyperbolic tangent of an angle</td>
<td valign="top">4</td>
</tr>
</tbody></table>
<br />
<hr />
<h3>
PHP Math Constants</h3>
<b>PHP</b>: indicates the earliest version of PHP that supports the
constant.<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table5" style="width: 100%px;">
<tbody>
<tr>
<th align="left" width="30%">Constant</th>
<th align="left" width="65%">Description</th>
<th align="left" width="5%">PHP</th>
</tr>
<tr>
<td valign="top">M_E</td>
<td valign="top">Returns e (approx. 2.718)</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top">M_EULER</td>
<td valign="top">Returns Euler's constant (approx. 0.577)</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top">M_LNPI</td>
<td valign="top">Returns the natural logarithm of PI (approx. 1.144)</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top">M_LN2</td>
<td valign="top">Returns the natural logarithm of 2 (approx. 0.693)</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top">M_LN10</td>
<td valign="top">Returns the natural logarithm of 10 (approx. 2.302)</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top">M_LOG2E</td>
<td valign="top">Returns the base-2 logarithm of E (approx. 1.442)</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top">M_LOG10E</td>
<td valign="top">Returns the base-10 logarithm of E (approx. 0.434)</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top">M_PI</td>
<td valign="top">Returns PI (approx. 3.14159)</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top">M_PI_2</td>
<td valign="top">Returns PI/2 (approx. 1.570)</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top">M_PI_4</td>
<td valign="top">Returns PI/4 (approx. 0.785)</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top">M_1_PI</td>
<td valign="top">Returns 1/PI (approx. 0.318)</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top">M_2_PI</td>
<td valign="top">Returns 2/PI (approx. 0.636)</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top">M_SQRTPI</td>
<td valign="top">Returns the square root of PI (approx. 1.772)</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top">M_2_SQRTPI</td>
<td valign="top">Returns 2/square root of PI (approx. 1.128)</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top">M_SQRT1_2</td>
<td valign="top">Returns the square root of 1/2 (approx. 0.707)</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top">M_SQRT2</td>
<td valign="top">Returns the square root of 2 (approx. 1.414)</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top">M_SQRT3</td>
<td valign="top">Returns the square root of 3 (approx. 1.732)</td>
<td valign="top">4</td>
</tr>
</tbody></table>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-357226456970214079.post-37487397746288500202023-07-29T10:23:00.001+05:302023-07-29T10:23:03.305+05:30PHP35-PHP Mail Functions<h3>
PHP Mail Introduction</h3>
The mail() function allows you to send emails directly from a script.<br />
<hr />
<h3>
Requirements</h3>
For the mail functions to be available, PHP requires an installed and working
email system. The program to be used is defined by
the configuration settings in the php.ini file.<br />
<hr />
<h3>
Installation</h3>
The mail functions are part of the PHP core. There is no installation
needed to use these functions.<br />
<hr />
<h3>
Runtime Configuration</h3>
The behavior of the mail functions is affected by settings in the php.ini
file.<br />
Mail configuration options:<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table5" style="width: 100%px;">
<tbody>
<tr>
<th align="left" valign="top" width="20%">Name</th>
<th align="left" valign="top" width="15%">Default</th>
<th align="left" valign="top" width="42%">Description</th>
<th align="left" valign="top" width="23%">Changeable</th>
</tr>
<tr>
<td valign="top">SMTP</td>
<td valign="top">"localhost"</td>
<td valign="top">Windows only: The DNS name or IP address of the SMTP
server</td>
<td valign="top">PHP_INI_ALL</td>
</tr>
<tr>
<td valign="top">smtp_port</td>
<td valign="top">"25"</td>
<td valign="top">Windows only: The SMTP port number. Available since PHP 4.3</td>
<td valign="top">PHP_INI_ALL</td>
</tr>
<tr>
<td valign="top">sendmail_from</td>
<td valign="top">NULL</td>
<td valign="top">Windows only: Specifies the "from" address to be used
in email sent from PHP</td>
<td valign="top">PHP_INI_ALL</td>
</tr>
<tr>
<td valign="top">sendmail_path</td>
<td valign="top">NULL</td>
<td valign="top">Unix systems only: Specifies where the sendmail program can be found (usually /usr/sbin/sendmail
or /usr/lib/sendmail)</td>
<td valign="top">PHP_INI_SYSTEM</td>
</tr>
</tbody></table>
<br />
<hr />
<h3>
PHP Mail Functions</h3>
<b>PHP</b>: indicates the earliest version of PHP that supports the
function.<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table4" style="width: 100%px;">
<tbody>
<tr>
<th align="left" valign="top" width="20%">Function</th>
<th align="left" valign="top" width="75%">Description</th>
<th align="left" valign="top" width="5%">PHP</th>
</tr>
<tr>
<td valign="top">ezmlm_hash()</td>
<td valign="top">Calculates the hash value needed by the EZMLM mailing
list system</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">mail()</a></td>
<td valign="top">Allows you to send emails directly from a script</td>
<td valign="top">3</td>
</tr>
</tbody></table>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-357226456970214079.post-33376907314127684982023-07-29T10:23:00.000+05:302023-07-29T10:23:01.052+05:30PHP34-PHP libxml Functions<h3>
PHP libxml Introduction</h3>
The libxml functions and constants are used together with SimpleXML, XSLT and
DOM functions.<br />
<hr />
<h3>
Installation</h3>
These functions require the libxml package.
<a href="http://www.blogger.com/blogger.g?blogID=357226456970214079" target="_blank">Download at xmlsoft.org</a><br />
<hr />
<h3>
PHP libxml Functions</h3>
<b>PHP</b>: indicates the earliest version of PHP that supports the
function.<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table4" style="width: 100%px;">
<tbody>
<tr>
<th align="left" valign="top" width="38%">Function</th>
<th align="left" valign="top" width="57%">Description</th>
<th align="left" valign="top" width="5%">PHP</th>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">libxml_clear_errors()</a></td>
<td valign="top">Clear libxml error buffer</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">libxml_get_errors()</a></td>
<td valign="top">Retrieve array of errors</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">libxml_get_last_error()</a></td>
<td valign="top">Retrieve last error from libxml</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top">libxml_set_streams_context()</td>
<td valign="top">Set the streams context for the next libxml document load
or write</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">libxml_use_internal_errors()</a></td>
<td valign="top">Disable libxml errors and allow user to fetch error
information as needed</td>
<td valign="top">5</td>
</tr>
</tbody></table>
<br />
<hr />
<h3>
PHP libxml Constants</h3>
<table border="1" cellspacing="0" class="ex" id="table5" style="width: 100%px;">
<tbody>
<tr>
<th align="left" valign="top" width="38%">Function</th>
<th align="left" valign="top" width="57%">Description</th>
<th align="left" valign="top" width="5%">PHP</th>
</tr>
<tr>
<td valign="top">LIBXML_COMPACT</td>
<td valign="top">Set small nodes allocation optimization. This may improve
the application performance</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top">LIBXML_DTDATTR</td>
<td valign="top">Set default DTD attributes</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top">LIBXML_DTDLOAD</td>
<td valign="top">Load external subset</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top">LIBXML_DTDVALID</td>
<td valign="top">Validate with the DTD</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top">LIBXML_NOBLANKS</td>
<td valign="top">Remove blank nodes</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top">LIBXML_NOCDATA</td>
<td valign="top">Set CDATA as text nodes</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top">LIBXML_NOEMPTYTAG</td>
<td valign="top">Change empty tags (e.g. <br/> to <br></br>),
only available in the DOMDocument->save() and DOMDocument->saveXML()
functions</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top">LIBXML_NOENT</td>
<td valign="top">Substitute entities</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top">LIBXML_NOERROR</td>
<td valign="top">Do not show error reports</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top">LIBXML_NONET</td>
<td valign="top">Stop network access while loading documents</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top">LIBXML_NOWARNING</td>
<td valign="top">Do not show warning reports</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top">LIBXML_NOXMLDECL</td>
<td valign="top">Drop the XML declaration when saving a document</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top">LIBXML_NSCLEAN</td>
<td valign="top">Remove excess namespace declarations</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top">LIBXML_XINCLUDE</td>
<td valign="top">Use XInclude substitution</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top">LIBXML_ERR_ERROR</td>
<td valign="top">Get recoverable errors</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top">LIBXML_ERR_FATAL</td>
<td valign="top">Get fatal errors</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top">LIBXML_ERR_NONE</td>
<td valign="top">Get no errors</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top">LIBXML_ERR_WARNING</td>
<td valign="top">Get simple warnings</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top">LIBXML_VERSION</td>
<td valign="top">Get libxml version (e.g. 20605 or 20617)</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top">LIBXML_DOTTED_VERSION</td>
<td valign="top">Get dotted libxml version (e.g. 2.6.5 or
2.6.17)</td>
<td valign="top">5</td>
</tr>
</tbody></table>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-357226456970214079.post-35803705367933024082023-07-29T10:22:00.006+05:302023-07-29T10:22:58.052+05:30PHP33-PHP HTTP Functions<h3>
PHP HTTP Introduction</h3>
The HTTP functions let you manipulate information sent to the browser by the
Web server, before any other output has been sent.<br />
<hr />
<h3>
Installation</h3>
The directory functions are part of the PHP core. There is no installation
needed to use these functions.<br />
<hr />
<h3>
PHP HTTP Functions</h3>
<b>PHP</b>: indicates the earliest version of PHP that supports the
function.<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table4" style="width: 100%px;">
<tbody>
<tr>
<th align="left" valign="top" width="38%">Function</th>
<th align="left" valign="top" width="57%">Description</th>
<th align="left" valign="top" width="5%">PHP</th>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">header()</a></td>
<td valign="top">Sends a raw HTTP header to a client</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">headers_list()</a></td>
<td valign="top">Returns a list of response headers sent (or ready to send)</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">headers_sent()</a></td>
<td valign="top">Checks if / where the HTTP headers have been sent</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">setcookie()</a></td>
<td valign="top">Sends an HTTP cookie to a client</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">setrawcookie()</a></td>
<td valign="top">Sends an HTTP cookie without URL encoding the cookie value</td>
<td valign="top">5</td>
</tr>
</tbody></table>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-357226456970214079.post-33773650240609087112023-07-29T10:22:00.005+05:302023-07-29T10:22:55.341+05:30PHP32- PHP FTP Functions<h3>
PHP FTP Introduction</h3>
The FTP functions give client access to file servers through the File
Transfer Protocol (FTP).<br />
<div style="text-align: justify;">
The FTP functions are used to open, login and close connections, as well as
upload, download, rename, delete, and get information on files from file
servers. Not all of the FTP functions will work with every server or return the
same results. The FTP functions became available with PHP 3.</div>
<div style="text-align: justify;">
These functions are meant for detailed access to an FTP server. If you only
wish to read from or write to a file on an FTP server, consider using the ftp://
wrapper with the Filesystem functions.</div>
<hr />
<h3>
Installation</h3>
The windows version of PHP has built-in support for the FTP extension.
So, the FTP functions will work automatically. <br />
However, if you are running the Linux version of PHP, you will have to compile PHP with <i>--enable-ftp </i>
(PHP 4+) or <i>--with-ftp</i> (PHP 3) to get the FTP functions to work.<br />
<hr />
<h3>
PHP FTP Functions</h3>
<b>PHP</b>: indicates the earliest version of PHP that supports the
function.<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table4" style="width: 100%px;">
<tbody>
<tr>
<th align="left" valign="top" width="30%">Function</th>
<th align="left" valign="top" width="65%">Description</th>
<th align="left" valign="top" width="5%">PHP</th>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">ftp_alloc()</a></td>
<td valign="top">Allocates space for a file to be uploaded to the FTP server</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">ftp_cdup()</a></td>
<td valign="top">Changes the current directory to the parent directory on
the FTP server</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">ftp_chdir()</a></td>
<td valign="top">Changes the current directory on the FTP server</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">ftp_chmod()</a></td>
<td valign="top">Sets permissions on a file via FTP</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">ftp_close()</a></td>
<td valign="top">Closes an FTP connection</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">ftp_connect()</a></td>
<td valign="top">Opens an FTP connection</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">ftp_delete()</a></td>
<td valign="top">Deletes a file on the FTP server</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">ftp_exec()</a></td>
<td valign="top">Executes a program/command on the FTP server</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">ftp_fget()</a></td>
<td valign="top">Downloads a file from the FTP server and saves it to an
open file</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">ftp_fput()</a></td>
<td valign="top">Uploads from an open file and saves it to a file on the FTP server</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">ftp_get_option()</a></td>
<td valign="top">Returns runtime behaviors of the FTP connection</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">ftp_get()</a></td>
<td valign="top">Downloads a file from the FTP server</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">ftp_login()</a></td>
<td valign="top">Logs on to an FTP connection</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">ftp_mdtm()</a></td>
<td valign="top">Returns the last modified time of a specified file</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">ftp_mkdir()</a></td>
<td valign="top">Creates a new directory on the FTP server</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">ftp_nb_continue()</a></td>
<td valign="top">Continues retrieving/sending a file (non-blocking)</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">ftp_nb_fget()</a></td>
<td valign="top">Downloads a file from the FTP server and saves it to an
open file (non-blocking)</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">ftp_nb_fput()</a></td>
<td valign="top">Uploads from an open file and saves it to a file on the FTP server
(non-blocking)</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">ftp_nb_get()</a></td>
<td valign="top">Downloads a file from the FTP server (non-blocking)</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">ftp_nb_put()</a></td>
<td valign="top">Uploads a file to the FTP server (non-blocking)</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">ftp_nlist()</a></td>
<td valign="top">Lists the files in a specified directory on the FTP server</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">ftp_pasv()</a></td>
<td valign="top">Turns passive mode on or off</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">ftp_put()</a></td>
<td valign="top">Uploads a file to the FTP server</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">ftp_pwd()</a></td>
<td valign="top">Returns the current directory name</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">ftp_quit()</a></td>
<td valign="top">Alias of ftp_close()</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">ftp_raw()</a></td>
<td valign="top">Sends a raw command to the FTP server</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">ftp_rawlist()</a></td>
<td valign="top">Returns a detailed list of files in the specified directory</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">ftp_rename()</a></td>
<td valign="top">Renames a file or directory on the FTP server</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">ftp_rmdir()</a></td>
<td valign="top">Removes a directory on the FTP server</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">ftp_set_option()</a></td>
<td valign="top">Sets runtime options for the FTP connection</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">ftp_site()</a></td>
<td valign="top">Sends a SITE command to the server</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">ftp_size()</a></td>
<td valign="top">Returns the size of the specified file</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">ftp_ssl_connect()</a></td>
<td valign="top">Opens a secure SSL-FTP connection</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">ftp_systype()</a></td>
<td valign="top">Returns the system type identifier of the FTP server</td>
<td valign="top">3</td>
</tr>
</tbody></table>
<br />
<hr />
<h3>
PHP FTP Constants</h3>
<b>PHP</b>: indicates the earliest version of PHP that supports the
constant.<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table5" style="width: 100%px;">
<tbody>
<tr>
<th align="left" width="30%">Constant</th>
<th align="left" width="65%">Description</th>
<th align="left" width="5%">PHP</th>
</tr>
<tr>
<td valign="top">FTP_ASCII</td>
<td valign="top"> </td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top">FTP_TEXT</td>
<td valign="top"> </td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top">FTP_BINARY</td>
<td valign="top"> </td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top">FTP_IMAGE</td>
<td valign="top"> </td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top">FTP_TIMEOUT_SEC</td>
<td valign="top"> </td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top">FTP_AUTOSEEK</td>
<td valign="top"> </td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top">FTP_AUTORESUME</td>
<td valign="top">Determine resume position and start position for get and
put requests automatically</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top">FTP_FAILED</td>
<td valign="top">Asynchronous transfer has failed</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top">FTP_FINISHED</td>
<td valign="top">Asynchronous transfer has finished</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top">FTP_MOREDATA</td>
<td valign="top">Asynchronous transfer is still active</td>
<td valign="top">4</td>
</tr>
</tbody></table>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-357226456970214079.post-87127717937477345542023-07-29T10:22:00.004+05:302023-07-29T10:22:52.972+05:30PHP29-PHP Error and Logging Functions<h3>
PHP Error and Logging Introduction</h3>
The error and logging functions allows error handling and logging.<br />
The error functions allow users to define error handling rules, and modify
the way the errors can be logged.<br />
The logging functions allow users to log applications and send log messages
to email, system logs or other machines.<br />
<hr />
<h3>
Installation</h3>
The error and logging functions are part of the PHP core. There is no installation needed
to use these functions.<br />
<hr />
<h3>
PHP Error and Logging Functions</h3>
<b>PHP</b>: indicates the earliest version of PHP that supports the
function.<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table4" style="width: 100%px;">
<tbody>
<tr>
<th align="left" valign="top" width="40%">Function</th>
<th align="left" valign="top" width="55%">Description</th>
<th align="left" valign="top" width="5%">PHP</th>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">debug_backtrace()</a></td>
<td valign="top">Generates a backtrace</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">debug_print_backtrace()</a></td>
<td valign="top">Prints a backtrace</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">error_get_last()</a></td>
<td valign="top">Gets the last error occurred</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">error_log()</a></td>
<td valign="top">Sends an error to the server error-log, to a file or to a remote
destination</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">error_reporting()</a></td>
<td valign="top">Specifies which errors are reported</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">restore_error_handler()</a></td>
<td valign="top">Restores the previous error handler</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">restore_exception_handler()</a></td>
<td valign="top">Restores the previous exception handler</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">set_error_handler()</a></td>
<td valign="top">Sets a user-defined function to handle errors</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">set_exception_handler()</a></td>
<td valign="top">Sets a user-defined function to handle exceptions</td>
<td valign="top">5</td>
</tr>
<tr>
<td height="26" valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">trigger_error()</a></td>
<td height="26" valign="top">Creates a user-defined error message</td>
<td height="26" valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">user_error()</a></td>
<td valign="top">Alias of trigger_error()</td>
<td valign="top">4</td>
</tr>
</tbody></table>
<br />
<hr />
<h3>
PHP Error and Logging Constants</h3>
<b>PHP</b>: indicates the earliest version of PHP that supports the
constant.<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table5" style="width: 100%px;">
<tbody>
<tr>
<th align="left" width="5%">Value</th>
<th align="left" width="35%">Constant</th>
<th align="left" width="55%">Description</th>
<th align="left" width="5%">PHP</th>
</tr>
<tr>
<td valign="top">1</td>
<td valign="top">E_ERROR</td>
<td valign="top">Fatal run-time errors. Errors that cannot be recovered from. Execution of the script is halted</td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">2</td>
<td valign="top">E_WARNING</td>
<td valign="top">Non-fatal run-time errors. Execution of the script is not halted</td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">4</td>
<td valign="top">E_PARSE</td>
<td valign="top">Compile-time parse errors. Parse errors should only be generated by the parser</td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">8</td>
<td valign="top">E_NOTICE</td>
<td valign="top">Run-time notices. The script found something that might be an error, but could also happen when running a script normally</td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">16</td>
<td valign="top">E_CORE_ERROR</td>
<td valign="top">Fatal errors at PHP startup. This is like an E_ERROR in the PHP core</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top">32</td>
<td valign="top">E_CORE_WARNING</td>
<td valign="top">Non-fatal errors at PHP startup. This is like an E_WARNING in the PHP core</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top">64</td>
<td valign="top">E_COMPILE_ERROR</td>
<td valign="top">Fatal compile-time errors. This is like an E_ERROR generated by the Zend Scripting Engine</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top">128</td>
<td valign="top">E_COMPILE_WARNING</td>
<td valign="top">Non-fatal compile-time errors. This is like an E_WARNING generated by the Zend Scripting Engine</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top">256</td>
<td valign="top">E_USER_ERROR</td>
<td valign="top">Fatal user-generated error. This is like an E_ERROR set by the programmer using the PHP function trigger_error()</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top">512</td>
<td valign="top">E_USER_WARNING</td>
<td valign="top">Non-fatal user-generated warning. This is like an E_WARNING set by the programmer using the PHP function trigger_error()</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top">1024</td>
<td valign="top">E_USER_NOTICE</td>
<td valign="top">User-generated notice. This is like an E_NOTICE set by the programmer using the PHP function trigger_error()</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top">2048</td>
<td valign="top">E_STRICT</td>
<td valign="top">Run-time notices. PHP suggest changes to your code to help interoperability and compatibility of the code</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top">4096</td>
<td valign="top">E_RECOVERABLE_ERROR</td>
<td valign="top">Catchable fatal error. This is like an E_ERROR but can be caught by a user defined handle (see also set_error_handler())</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top">8191</td>
<td valign="top">E_ALL</td>
<td valign="top">All errors and warnings, except of level E_STRICT</td>
<td valign="top">5</td>
</tr>
</tbody></table>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-357226456970214079.post-20217576721453029462023-07-29T10:22:00.003+05:302023-07-29T10:22:19.101+05:30PHP30-PHP Filesystem Functions<h3>
PHP Filesystem Introduction</h3>
The filesystem functions allow you to access and manipulate the filesystem.<br />
<hr />
<h3>
Installation</h3>
The filesystem functions are part of the PHP core. There is no installation
needed to use these functions.<br />
<hr />
<h3>
Runtime Configuration</h3>
The behavior of the filesystem functions is affected by settings in php.ini.<br />
Filesystem configuration options:<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table6" style="width: 100%px;">
<tbody>
<tr>
<th align="left" valign="top" width="20%">Name</th>
<th align="left" valign="top" width="15%">Default</th>
<th align="left" valign="top" width="42%">Description</th>
<th align="left" valign="top" width="23%">Changeable</th>
</tr>
<tr>
<td valign="top">allow_url_fopen</td>
<td valign="top">"1"</td>
<td valign="top">Allows fopen()-type functions to work with URLs (available since PHP 4.0.4)</td>
<td valign="top">PHP_INI_SYSTEM </td>
</tr>
<tr>
<td valign="top">user_agent</td>
<td valign="top">NULL</td>
<td valign="top">Defines the user agent for PHP to send (available since PHP
4.3) </td>
<td valign="top">PHP_INI_ALL</td>
</tr>
<tr>
<td valign="top">default_socket_timeout</td>
<td valign="top">"60"</td>
<td valign="top">Sets the default timeout, in seconds, for socket based streams
(available since PHP 4.3) </td>
<td valign="top">PHP_INI_ALL</td>
</tr>
<tr>
<td valign="top">from</td>
<td valign="top">""</td>
<td valign="top">Defines the anonymous FTP password (your email address)</td>
<td valign="top">PHP_INI_ALL</td>
</tr>
<tr>
<td valign="top">auto_detect_line_endings</td>
<td valign="top">"0"</td>
<td valign="top">When set to "1", PHP will examine the data read by fgets()
and file() to see if it is using Unix, MS-Dos or Mac line-ending characters
(available since PHP 4.3)</td>
<td valign="top">PHP_INI_ALL</td>
</tr>
</tbody></table>
<br />
<hr />
<h3>
Unix / Windows Compatibility</h3>
When specifying a path on Unix platforms, the forward slash (/) is
used as directory separator. However, on Windows platforms, both
forward slash (/) and backslash (\) can be used.<br />
<hr />
<h3>
PHP Filesystem Functions</h3>
<b>PHP</b>: indicates the earliest version of PHP that supports the
function.<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table4" style="width: 100%px;">
<tbody>
<tr>
<th align="left" valign="top" width="30%">Function</th>
<th align="left" valign="top" width="65%">Description</th>
<th align="left" valign="top" width="5%">PHP</th>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">basename()</a></td>
<td valign="top">Returns the filename component of a path</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">chgrp()</a></td>
<td valign="top">Changes the file group</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">chmod()</a></td>
<td valign="top">Changes the file mode</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">chown()</a></td>
<td valign="top">Changes the file owner</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">clearstatcache()</a></td>
<td valign="top">Clears the file status cache</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">copy()</a></td>
<td valign="top">Copies a file</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top">delete()</td>
<td valign="top">See unlink() or unset()</td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">dirname()</a></td>
<td valign="top">Returns the directory name component of a path</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">disk_free_space()</a></td>
<td valign="top">Returns the free space of a directory</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">disk_total_space()</a></td>
<td valign="top">Returns the total size of a directory</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">diskfreespace()</a></td>
<td valign="top">Alias of disk_free_space()</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">fclose()</a></td>
<td valign="top">Closes an open file</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">feof()</a></td>
<td valign="top">Tests for end-of-file on an open file</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">fflush()</a></td>
<td valign="top">Flushes buffered output to an open file</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">fgetc()</a></td>
<td valign="top">Returns a character from an open file</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">fgetcsv()</a></td>
<td valign="top">Parses a line from an open file, checking for
<span lang="en-us">CSV fields</span></td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">fgets()</a></td>
<td valign="top">Returns a line from an open file</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">fgetss()</a></td>
<td valign="top">Returns a line, with HTML and PHP tags removed, from an
open file</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">file()</a></td>
<td valign="top">Reads a file into an array</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">file_exists()</a></td>
<td valign="top">Checks whether or not a file or directory exists</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">file_get_contents()</a></td>
<td valign="top">Reads a file into a string</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">file_put_contents</a></td>
<td valign="top">Writes a string to a file</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">fileatime()</a></td>
<td valign="top">Returns the last access time of a file</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">filectime()</a></td>
<td valign="top">Returns the last change time of a file</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">filegroup()</a></td>
<td valign="top">Returns the group ID of a file</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">fileinode()</a></td>
<td valign="top">Returns the inode number of a file</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">filemtime()</a></td>
<td valign="top">Returns the last modification time of a file</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">fileowner()</a></td>
<td valign="top">Returns the user ID (owner) of a file</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">fileperms()</a></td>
<td valign="top">Returns the permissions of a file</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">filesize()</a></td>
<td valign="top">Returns the file size</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">filetype()</a></td>
<td valign="top">Returns the file type</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">flock()</a></td>
<td valign="top">Locks or releases a file</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">fnmatch()</a></td>
<td valign="top">Matches a filename or string against a specified pattern</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">fopen()</a></td>
<td valign="top">Opens a file or URL</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">fpassthru()</a></td>
<td valign="top">Reads from an
open file, until EOF, and writes the result to the output buffer</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">fputcsv()</a></td>
<td valign="top">Formats a line as CSV and writes it to an open file</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">fputs()</a></td>
<td valign="top">Alias of fwrite()</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">fread()</a></td>
<td valign="top">Reads from an open file</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">fscanf()</a></td>
<td valign="top">Parses input from an open file according to a specified format</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">fseek()</a></td>
<td valign="top">Seeks in an open file</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">fstat()</a></td>
<td valign="top">Returns information about an open file</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">ftell()</a></td>
<td valign="top">Returns the current position in an open file</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">ftruncate()</a></td>
<td valign="top">Truncates an open file to a specified length</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">fwrite()</a></td>
<td valign="top">Writes to an open file</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">glob()</a></td>
<td valign="top">Returns an array of filenames / directories matching a
specified pattern</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">is_dir()</a></td>
<td valign="top">Checks whether a file is a directory</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">is_executable()</a></td>
<td valign="top">Checks whether a file is executable</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">is_file()</a></td>
<td valign="top">Checks whether a file is a regular file</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">is_link()</a></td>
<td valign="top">Checks whether a file is a link</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">is_readable()</a></td>
<td valign="top">Checks whether a file is readable</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">is_uploaded_file()</a></td>
<td valign="top">Checks whether a file was uploaded via HTTP POST</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">is_writable()</a></td>
<td valign="top">Checks whether a file is writeable</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">is_writeable()</a></td>
<td valign="top">Alias of is_writable()</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">link()</a></td>
<td valign="top">Creates a hard link</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">linkinfo()</a></td>
<td valign="top">Returns information about a hard link</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">lstat()</a></td>
<td valign="top">Returns information about a file or symbolic link</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">mkdir()</a></td>
<td valign="top">Creates a directory</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">move_uploaded_file()</a></td>
<td valign="top">Moves an uploaded file to a new location</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">parse_ini_file()</a></td>
<td valign="top">Parses a configuration file</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">pathinfo()</a></td>
<td valign="top">Returns information about a file path</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">pclose()</a></td>
<td valign="top">Closes a pipe opened by popen()</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">popen()</a></td>
<td valign="top">Opens a pipe</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">readfile()</a></td>
<td valign="top">Reads a file and writes it to the output buffer</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">readlink()</a></td>
<td valign="top">Returns the target of a symbolic link</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">realpath()</a></td>
<td valign="top">Returns the absolute pathname</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">rename()</a></td>
<td valign="top">Renames a file or directory</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">rewind()</a></td>
<td valign="top">Rewinds a file pointer</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">rmdir()</a></td>
<td valign="top">Removes an empty directory</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">set_file_buffer()</a></td>
<td valign="top">Sets the buffer size of an open file</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">stat()</a></td>
<td valign="top">Returns information about a file</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">symlink()</a></td>
<td valign="top">Creates a symbolic link</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">tempnam()</a></td>
<td valign="top">Creates a unique temporary file</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">tmpfile()</a></td>
<td valign="top">Creates a unique temporary file</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">touch()</a></td>
<td valign="top">Sets access and modification time of a file</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">umask()</a></td>
<td valign="top">Changes file permissions for files</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">unlink()</a></td>
<td valign="top">Deletes a file</td>
<td valign="top">3</td>
</tr>
</tbody></table>
<br />
<hr />
<h3>
PHP Filesystem Constants</h3>
<b>PHP</b>: indicates the earliest version of PHP that supports the
constant.<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table5" style="width: 100%px;">
<tbody>
<tr>
<th align="left" width="35%">Constant</th>
<th align="left" width="60%">Description</th>
<th align="left" width="5%">PHP</th>
</tr>
<tr>
<td valign="top">GLOB_BRACE</td>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">GLOB_ONLYDIR</td>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">GLOB_MARK</td>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">GLOB_NOSORT</td>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">GLOB_NOCHECK</td>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">GLOB_NOESCAPE</td>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">PATHINFO_DIRNAME</td>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">PATHINFO_BASENAME</td>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">PATHINFO_EXTENSION</td>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">FILE_USE_INCLUDE_PATH</td>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">FILE_APPEND</td>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">FILE_IGNORE_NEW_LINES</td>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">FILE_SKIP_EMPTY_LINES</td>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
</tbody></table>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-357226456970214079.post-37316555099498564262023-07-29T10:22:00.002+05:302023-07-29T10:22:05.085+05:30PHP27-PHP Date / Time Functions<h3>
PHP Date / Time Introduction</h3>
The date/time functions allow you to extract and format the date and time on
the server.<br />
<b>Note:</b> These functions depend on the
locale settings of the server!<br />
<hr />
<h3>
Installation</h3>
The date/time functions are part of the PHP core. There is no installation
needed to use these functions.<br />
<hr />
<h3>
Runtime Configuration</h3>
The behavior of the date/time functions is affected by settings in php.ini.<br />
Date/Time configuration options:<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table6" style="width: 100%px;">
<tbody>
<tr>
<th align="left" valign="top" width="20%">Name</th>
<th align="left" valign="top" width="15%">Default</th>
<th align="left" valign="top" width="42%">Description</th>
<th align="left" valign="top" width="23%">Changeable</th>
</tr>
<tr>
<td valign="top">date.default_latitude</td>
<td valign="top"> "31.7667"</td>
<td valign="top">Specifies the default latitude (available since PHP 5).
This option is used by date_sunrise() and date_sunset()</td>
<td valign="top">PHP_INI_ALL</td>
</tr>
<tr>
<td valign="top">date.default_longitude</td>
<td valign="top">"35.2333"</td>
<td valign="top">Specifies the default longitude (available since PHP 5).
This option is used by date_sunrise() and date_sunset()</td>
<td valign="top">PHP_INI_ALL</td>
</tr>
<tr>
<td valign="top">date.sunrise_zenith</td>
<td valign="top">"90.83"</td>
<td valign="top">Specifies the default sunrise zenith (available since PHP
5). This option is used by date_sunrise() and date_sunset()</td>
<td valign="top">PHP_INI_ALL</td>
</tr>
<tr>
<td valign="top">date.sunset_zenith</td>
<td valign="top">"90.83"</td>
<td valign="top">Specifies the default sunset zenith (available since PHP
5). This option is used by date_sunrise() and date_sunset()</td>
<td valign="top">PHP_INI_ALL</td>
</tr>
<tr>
<td valign="top">date.timezone</td>
<td valign="top">""</td>
<td valign="top">Specifies the default timezone (available since PHP 5.1)</td>
<td valign="top">PHP_INI_ALL</td>
</tr>
</tbody></table>
<br />
<hr />
<h3>
PHP Date / Time Functions</h3>
<b>PHP</b>: indicates the earliest version of PHP that supports the
function.<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table4" style="width: 100%px;">
<tbody>
<tr>
<th align="left" valign="top" width="38%">Function</th>
<th align="left" valign="top" width="57%">Description</th>
<th align="left" valign="top" width="5%">PHP</th>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">checkdate()</a></td>
<td valign="top">Validates a Gregorian date</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">date_default_timezone_get()</a></td>
<td valign="top">Returns the default time zone</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">date_default_timezone_set()</a></td>
<td valign="top">Sets the default time zone</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">date_sunrise()</a></td>
<td valign="top">Returns the time of sunrise for a given day / location</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">date_sunset()</a></td>
<td valign="top">Returns the time of sunset for a given day / location</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">date()</a></td>
<td valign="top">Formats a local time/date</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">getdate()</a></td>
<td valign="top">Returns an array that contains date and time information
for a Unix timestamp</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">gettimeofday()</a></td>
<td valign="top">Returns an array that contains current time information</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">gmdate()</a></td>
<td valign="top">Formats a GMT/UTC date/time</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">gmmktime()</a></td>
<td valign="top">Returns the Unix timestamp for a GMT date</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">gmstrftime()</a></td>
<td valign="top">Formats a GMT/UTC time/date according to locale settings</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">idate()</a></td>
<td valign="top">Formats a local time/date as integer</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">localtime()</a></td>
<td valign="top">Returns an array that contains the time components of a
Unix timestamp</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">microtime()</a></td>
<td valign="top">Returns the microseconds for the current time</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">mktime()</a></td>
<td valign="top">Returns the Unix timestamp for a date</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">strftime()</a></td>
<td valign="top">Formats a local time/date according to locale settings</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">strptime()</a></td>
<td valign="top">Parses a time/date generated with strftime()</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">strtotime()</a></td>
<td valign="top">Parses an English textual date or time into a Unix
timestamp</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">time()</a></td>
<td valign="top">Returns the current time as a Unix timestamp</td>
<td valign="top">3</td>
</tr>
</tbody></table>
<br />
<hr />
<h3>
PHP Date / Time Constants</h3>
<b>PHP</b>: indicates the earliest version of PHP that supports the
constant.<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table5" style="width: 100%px;">
<tbody>
<tr>
<th align="left" width="38%">Constant</th>
<th align="left" width="57%">Description</th>
<th align="left" width="5%">PHP</th>
</tr>
<tr>
<td valign="top">DATE_ATOM</td>
<td valign="top">Atom (example: 2005-08-15T16:13:03+0000)</td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">DATE_COOKIE</td>
<td valign="top">HTTP Cookies (example: Sun, 14 Aug 2005 16:13:03 UTC)</td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">DATE_ISO8601</td>
<td valign="top">ISO-8601 (example: 2005-08-14T16:13:03+0000)</td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">DATE_RFC822</td>
<td valign="top">RFC 822 (example: Sun, 14 Aug 2005 16:13:03 UTC)</td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">DATE_RFC850</td>
<td valign="top">RFC 850 (example: Sunday, 14-Aug-05 16:13:03 UTC)</td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">DATE_RFC1036</td>
<td valign="top">RFC 1036 (example: Sunday, 14-Aug-05 16:13:03 UTC)</td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">DATE_RFC1123</td>
<td valign="top">RFC 1123 (example: Sun, 14 Aug 2005 16:13:03 UTC)</td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">DATE_RFC2822</td>
<td valign="top">RFC 2822 (Sun, 14 Aug 2005 16:13:03 +0000)</td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">DATE_RSS</td>
<td valign="top">RSS (Sun, 14 Aug 2005 16:13:03 UTC)</td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">DATE_W3C</td>
<td valign="top">World Wide Web Consortium (example:
2005-08-14T16:13:03+0000)</td>
<td valign="top"> </td>
</tr>
</tbody></table>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-357226456970214079.post-72362995084000021642023-07-29T10:22:00.001+05:302023-07-29T10:22:02.479+05:30PHP26-PHP Calendar Functions<h3>
PHP Calendar Introduction</h3>
The calendar functions are useful when working with different calendar formats. The standard it is based on is the Julian
day count (Julian day count is a count of days starting from January 1, 4713 B.C.).
Note that the Julian day count is not the same as the Julian calendar!<br />
<b>Note:</b> To convert between calendar formats, you must first convert to Julian
day
count, then to the calendar format.<br />
<hr />
<h3>
Installation</h3>
The windows version of PHP has built-in support for the calendar extension.
So, the calendar functions will work automatically. <br />
However, if you are running the Linux version of PHP, you will have to compile PHP with <i>--enable-calendar </i>to get the
calendar functions to work.<br />
<hr />
<h3>
PHP Calendar Functions</h3>
<b>PHP</b>: indicates the earliest version of PHP that supports the
function.<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table4" style="width: 100%px;">
<tbody>
<tr>
<th align="left" valign="top" width="30%">Function</th>
<th align="left" valign="top" width="64%">Description</th>
<th align="left" valign="top" width="5%">PHP</th>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">cal_days_in_month()</a></td>
<td valign="top">Returns the number of days in a month for a specified year and
calendar</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">cal_from_jd()</a></td>
<td valign="top">Converts a Julian day count into a date of a specified
calendar</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">cal_info()</a></td>
<td valign="top">Returns information about a given calendar</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">cal_to_jd()</a></td>
<td valign="top">Converts a date to Julian day count</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">easter_date()</a></td>
<td valign="top">Returns the Unix timestamp for midnight on Easter of a
specified
year</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">easter_days()</a></td>
<td valign="top">Returns the number of days after March 21, on which Easter
falls for a specified year</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">FrenchToJD()</a></td>
<td valign="top">Converts a French Republican date to a
Julian day count</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">GregorianToJD()</a></td>
<td valign="top">Converts a Gregorian date to a Julian day count</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">JDDayOfWeek()</a></td>
<td valign="top">Returns the day of a week</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">JDMonthName()</a></td>
<td valign="top">Returns a month name</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">JDToFrench()</a></td>
<td valign="top">Converts a Julian day count to a French Republican
date</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">JDToGregorian()</a></td>
<td valign="top">Converts a Julian day count to a Gregorian date</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">jdtojewish()</a></td>
<td valign="top">Converts a Julian day count to a Jewish date</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">JDToJulian()</a></td>
<td valign="top">Converts a Julian day count to a Julian date</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">jdtounix()</a></td>
<td valign="top">Converts a Julian day count to a Unix timestamp</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">JewishToJD()</a></td>
<td valign="top">Converts a Jewish date to a Julian day count</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">JulianToJD()</a></td>
<td valign="top">Converts a Julian date to a Julian day count</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">unixtojd()</a></td>
<td valign="top">Converts a Unix timestamp to a Julian day count</td>
<td valign="top">4</td>
</tr>
</tbody></table>
<br />
<hr />
<h3>
PHP Calendar Constants</h3>
<b>PHP</b>: indicates the earliest version of PHP that supports the
constant.<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table5" style="width: 100%px;">
<tbody>
<tr>
<th align="left" width="45%">Constant</th>
<th align="left" width="50%">Description</th>
<th align="left" width="5%">PHP</th>
</tr>
<tr>
<td valign="top">CAL_GREGORIAN</td>
<td valign="top">Gregorian calendar</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top">CAL_JULIAN</td>
<td valign="top">Julian calendar</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top">CAL_JEWISH</td>
<td valign="top">Jewish calendar</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top">CAL_FRENCH</td>
<td valign="top">French Republican calendar</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top">CAL_NUM_CALS</td>
<td valign="top"> </td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top">CAL_DOW_DAYNO</td>
<td valign="top"> </td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top">CAL_DOW_SHORT</td>
<td valign="top"> </td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top">CAL_DOW_LONG</td>
<td valign="top"> </td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top">CAL_MONTH_GREGORIAN_SHORT</td>
<td valign="top"> </td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top">CAL_MONTH_GREGORIAN_LONG</td>
<td valign="top"> </td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top">CAL_MONTH_JULIAN_SHORT</td>
<td valign="top"> </td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top">CAL_MONTH_JULIAN_LONG</td>
<td valign="top"> </td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top">CAL_MONTH_JEWISH</td>
<td valign="top"> </td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top">CAL_MONTH_FRENCH</td>
<td valign="top"> </td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top">CAL_EASTER_DEFAULT</td>
<td valign="top"> </td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top">CAL_EASTER_DEFAULT</td>
<td valign="top"> </td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top">CAL_EASTER_ROMAN</td>
<td valign="top"> </td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top">CAL_EASTER_ALWAYS_GREGORIAN</td>
<td valign="top"> </td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top">CAL_EASTER_ALWAYS_JULIAN</td>
<td valign="top"> </td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top">CAL_JEWISH_ADD_ALAFIM_GERESH</td>
<td valign="top"> </td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top">CAL_JEWISH_ADD_ALAFIM</td>
<td valign="top"> </td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top">CAL_JEWISH_ADD_GERESHAYIM</td>
<td valign="top"> </td>
<td valign="top">5</td>
</tr>
</tbody></table>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-357226456970214079.post-55949065138217893512023-07-29T10:22:00.000+05:302023-07-29T10:22:00.196+05:30PHP25-PHP Array Functions<h3>
PHP Array Introduction</h3>
The array functions allow you to manipulate arrays.<br />
PHP supports both simple and multi-dimensional arrays. There are also
specific functions for populating arrays from database queries.<br />
<hr />
<h3>
Installation</h3>
The array functions are part of the PHP core. There is no installation needed
to use these functions.<br />
<hr />
<h3>
PHP Array Functions</h3>
<b>PHP</b>: indicates the earliest version of PHP that supports the
function.<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table4" style="width: 100%px;">
<tbody>
<tr>
<th align="left" valign="top" width="35%">Function</th>
<th align="left" valign="top" width="60%">Description</th>
<th align="left" valign="top" width="5%">PHP</th>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array()</a></td>
<td valign="top">Creates an array</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_change_key_case()</a></td>
<td valign="top">Returns an array with all keys in lowercase or uppercase</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_chunk()</a></td>
<td valign="top">Splits an array into chunks of arrays</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_combine()</a></td>
<td valign="top">Creates an array by using one array for keys and another for its values</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_count_values()</a></td>
<td valign="top">Returns an array with the number of occurrences for each value</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_diff()</a></td>
<td valign="top">Compares array values, and returns the differences</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_diff_assoc()</a></td>
<td valign="top">Compares array keys and values, and returns the differences</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_diff_key()</a></td>
<td valign="top">Compares array keys, and returns the differences</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_diff_uassoc()</a></td>
<td valign="top">Compares array keys and values, with an additional user-made function check, and returns the differences</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_diff_ukey()</a></td>
<td valign="top">Compares array keys, with an additional user-made function check, and returns the differences</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_fill()</a></td>
<td valign="top">Fills an array with values</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_filter()</a></td>
<td valign="top">Filters elements of an array using a user-made function</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_flip()</a></td>
<td valign="top">Exchanges all keys with their associated values in an array</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_intersect()</a></td>
<td valign="top">Compares array values, and returns the matches</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_intersect_assoc()</a></td>
<td valign="top">Compares array keys and values, and returns the matches</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_intersect_key()</a></td>
<td valign="top">Compares array keys, and returns the matches</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_intersect_uassoc()</a></td>
<td valign="top">Compares array keys and values, with an additional user-made function check, and returns the matches</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_intersect_ukey()</a></td>
<td valign="top">Compares array keys, with an additional user-made function check, and returns the matches</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_key_exists()</a></td>
<td valign="top">Checks if the specified key exists in the array</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_keys()</a></td>
<td valign="top">Returns all the keys of an array</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_map()</a></td>
<td valign="top">Sends each value of an array to a user-made function, which returns new values</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_merge()</a></td>
<td valign="top">Merges one or more arrays into one array</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_merge_recursive()</a></td>
<td valign="top">Merges one or more arrays into one array</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_multisort()</a></td>
<td valign="top">Sorts multiple or multi-dimensional arrays</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_pad()</a></td>
<td valign="top">Inserts a specified number of items, with a specified value, to an array</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_pop()</a></td>
<td valign="top">Deletes the last element of an array</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_product()</a></td>
<td valign="top">Calculates the product of the values in an array</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_push()</a></td>
<td valign="top">Inserts one or more elements to the end of an array</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_rand()</a></td>
<td valign="top">Returns one or more random keys from an array</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_reduce()</a></td>
<td valign="top">Returns an array as a string, using a user-defined function</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_reverse()</a></td>
<td valign="top">Returns an array in the reverse order</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_search()</a></td>
<td valign="top">Searches an array for a given value and returns the key</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_shift()</a></td>
<td valign="top">Removes the first element from an array, and returns the value of the removed element</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_slice()</a></td>
<td valign="top">Returns selected parts of an array</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_splice()</a></td>
<td valign="top">Removes and replaces specified elements of an array</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_sum()</a></td>
<td valign="top">Returns the sum of the values in an array</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_udiff()</a></td>
<td valign="top">Compares array values in a user-made function and returns an array</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_udiff_assoc()</a></td>
<td valign="top">Compares array keys, and compares array values in a user-made function, and returns an array</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_udiff_uassoc()</a></td>
<td valign="top">Compares array keys and array values in user-made functions, and returns an array</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_uintersect()</a></td>
<td valign="top">Compares array values in a user-made function and returns an array</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_uintersect_assoc()</a></td>
<td valign="top">Compares array keys, and compares array values in a user-made function, and returns an array</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_uintersect_uassoc()</a></td>
<td valign="top">Compares array keys and array values in user-made functions, and returns an array</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_unique()</a></td>
<td valign="top">Removes duplicate values from an array</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_unshift()</a></td>
<td valign="top">Adds one or more elements to the beginning of an array</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_values()</a></td>
<td valign="top">Returns all the values of an array</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_walk()</a></td>
<td valign="top">Applies a user function to every member of an array</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">array_walk_recursive()</a></td>
<td valign="top">Applies a user function recursively to every member of an
array</td>
<td valign="top">5</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">arsort()</a></td>
<td valign="top">Sorts an array in reverse order and maintain index
association</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">asort()</a></td>
<td valign="top">Sorts an array and maintain index association</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">compact()</a></td>
<td valign="top">Create array containing variables and their values</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">count()</a></td>
<td valign="top">Counts elements in an array, or properties in an object</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">current()</a></td>
<td valign="top">Returns the current element in an array</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">each()</a></td>
<td valign="top">Returns the current key and value pair from an array</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">end()</a></td>
<td valign="top">Sets the internal pointer of an array to its last element</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">extract()</a></td>
<td valign="top">Imports variables into the current symbol table from an
array</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">in_array()</a></td>
<td valign="top">Checks if a specified value exists in an array</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">key()</a></td>
<td valign="top">Fetches a key from an array</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">krsort()</a></td>
<td valign="top">Sorts an array by key in reverse order</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">ksort()</a></td>
<td valign="top">Sorts an array by key</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">list()</a></td>
<td valign="top">Assigns variables as if they were an array</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">natcasesort()</a></td>
<td valign="top">Sorts an array using a case insensitive "natural order"
algorithm</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">natsort()</a></td>
<td valign="top">Sorts an array using a "natural order" algorithm</td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">next()</a></td>
<td valign="top">Advance the internal array pointer of an array</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">pos()</a></td>
<td valign="top">Alias of current()</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">prev()</a></td>
<td valign="top">Rewinds the internal array pointer</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">range()</a></td>
<td valign="top">Creates an array containing a range of elements</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">reset()</a></td>
<td valign="top">Sets the internal pointer of an array to its first element</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">rsort()</a></td>
<td valign="top">Sorts an array in reverse order</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">shuffle()</a></td>
<td valign="top">Shuffles an array</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">sizeof()</a></td>
<td valign="top">Alias of count()</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">sort()</a></td>
<td valign="top">Sorts an array</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">uasort()</a></td>
<td valign="top">Sorts an array with a user-defined function and
maintain index association</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">uksort()</a></td>
<td valign="top">Sorts an array by keys using a user-defined function</td>
<td valign="top">3</td>
</tr>
<tr>
<td valign="top"><a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">usort()</a></td>
<td valign="top">Sorts an array by values using a user-defined
function</td>
<td valign="top">3</td>
</tr>
</tbody></table>
<br />
<hr />
<h3>
PHP Array Constants</h3>
<b>PHP</b>: indicates the earliest version of PHP that supports the
constant.<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table5" style="width: 100%px;">
<tbody>
<tr>
<th align="left" width="35%">Constant</th>
<th align="left" width="60%">Description</th>
<th align="left" width="5%">PHP</th>
</tr>
<tr>
<td valign="top">CASE_LOWER</td>
<td valign="top">Used with array_change_key_case() to convert array keys to
lower case</td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">CASE_UPPER</td>
<td valign="top">Used with array_change_key_case() to convert array keys to
upper case</td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">SORT_ASC</td>
<td valign="top">Used with array_multisort() to sort in ascending order</td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">SORT_DESC</td>
<td valign="top">Used with array_multisort() to sort in descending order</td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">SORT_REGULAR</td>
<td valign="top">Used to compare items normally</td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">SORT_NUMERIC</td>
<td valign="top">Used to compare items numerically</td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">SORT_STRING</td>
<td valign="top">Used to compare items as strings</td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">SORT_LOCALE_STRING</td>
<td valign="top">Used to compare items as strings, based on the current
locale </td>
<td valign="top">4</td>
</tr>
<tr>
<td valign="top">COUNT_NORMAL</td>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">COUNT_RECURSIVE</td>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">EXTR_OVERWRITE</td>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">EXTR_SKIP</td>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">EXTR_PREFIX_SAME</td>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">EXTR_PREFIX_ALL</td>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">EXTR_PREFIX_INVALID</td>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">EXTR_PREFIX_IF_EXISTS</td>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">EXTR_IF_EXISTS</td>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
<tr>
<td valign="top">EXTR_REFS</td>
<td valign="top"> </td>
<td valign="top"> </td>
</tr>
</tbody></table>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-357226456970214079.post-32621920486159900382023-07-29T10:21:00.016+05:302023-07-29T10:21:57.447+05:30PHP24- PHP Filter<div class="intro">
PHP filters are used to validate and filter data coming from
insecure sources, like user input.</div>
<hr />
<h3>
What is a PHP Filter? </h3>
A PHP filter is used to validate and filter data coming from insecure sources.<br />
To test, validate and filter user input or custom data is an important part
of any web application.<br />
The PHP filter extension is designed to make data
filtering easier and quicker.<br />
<hr />
<h3>
Why use a Filter?</h3>
<div style="text-align: justify;">
Almost all web applications depend on external input. Usually this comes from
a user or another application (like a web service). By using filters you can be
sure your application gets the correct input type.</div>
<b>You should always filter all external data!</b><br />
Input filtering is one of the most important application security issues.<br />
What is external data?<br />
<ul>
<li>Input data from a form</li>
<li>Cookies</li>
<li>Web services data</li>
<li>Server variables</li>
<li>Database query results</li>
</ul>
<hr />
<h3>
Functions and Filters</h3>
To filter a variable, use one of the following filter functions:<br />
<ul>
<li>filter_var() - Filters a single variable with a specified filter</li>
<li>filter_var_array() - Filter several variables with the same or different
filters</li>
<li>filter_input - Get one input variable and filter it</li>
<li>filter_input_array - Get several input variables and filter them with
the same or different filters</li>
</ul>
In the example below, we validate an integer using the filter_var() function:<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table13" style="width: 100%px;"><tbody>
<tr><td>
<pre><?php
$int = 123;</pre>
<pre>if(!filter_var($int, FILTER_VALIDATE_INT))
{
echo("Integer is not valid");
}
else
{
echo("Integer is valid");
}
?></pre>
</td></tr>
</tbody></table>
<br />
<div style="text-align: justify;">
The code above uses the "FILTER_VALIDATE_INT" filter to filter the
variable. Since the integer is valid, the output of the code above will be:
"Integer is valid".</div>
If we try with a variable that is not an integer (like "123abc"), the output
will be: "Integer is not valid".<br />
For a complete list of functions and filters, visit our
<a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">PHP Filter Reference.</a><br />
<br />
<hr />
<h3>
Validating and Sanitizing</h3>
There are two kinds of filters:<br />
Validating filters:<br />
<ul>
<li>Are used to validate user input</li>
<li>Strict format rules (like URL or E-Mail validating)</li>
<li>Returns the expected type on success or FALSE on failure</li>
</ul>
Sanitizing filters:<br />
<ul>
<li>Are used to allow or disallow specified characters in a string</li>
<li>No data format rules</li>
<li>Always return the string</li>
</ul>
<hr />
<h3>
Options and Flags</h3>
Options and flags are used to add additional filtering options to the
specified filters.<br />
Different filters have different options and flags.<br />
<br />
In the example below, we validate an integer using the filter_var() and the "min_range"
and "max_range" options:<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table14" style="width: 100%px;"><tbody>
<tr><td>
<pre><?php
$var=300;</pre>
<pre>$int_options = array(
"options"=>array
(
"min_range"=>0,
"max_range"=>256
)
);</pre>
<pre>if(!filter_var($var, FILTER_VALIDATE_INT, $int_options))
{
echo("Integer is not valid");
}
else
{
echo("Integer is valid");
}
?></pre>
</td></tr>
</tbody></table>
<br />
Like the code above, options must be put in an associative array with the
name "options". If a flag is used it does not need to be in an array.<br />
Since the integer is "300" it is not in the specified range, and the output of the code above will be:
"Integer is not valid".<br />
For a complete list of functions and filters, visit our
<a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">PHP Filter Reference.</a> Check each filter to see
what options and flags are available.<br />
<hr />
<h3>
Validate Input</h3>
Let's try validating input from a form.<br />
The first thing we need to do is to confirm that the input data we are
looking for exists.<br />
Then we filter the input data using the filter_input() function.<br />
In the example below, the input variable "email" is sent to the PHP page:<br />
<table border="1" cellspacing="0" class="ex" id="table3" style="width: 100%px;"><tbody>
<tr><td>
<pre><?php
if(!filter_has_var(INPUT_GET, "email"))
{
echo("Input type does not exist");
}
else
{
if (!filter_input(INPUT_GET, "email", FILTER_VALIDATE_EMAIL))
{
echo "E-Mail is not valid";
}
else
{
echo "E-Mail is valid";
}
}
?></pre>
</td></tr>
</tbody></table>
<h4>
Example Explained</h4>
The example above has an input (email) sent to it using the "GET" method:<br />
<ol>
<li>Check if an "email" input variable of the "GET" type exist</li>
<li>If the input variable exists, check if it is a valid e-mail address</li>
</ol>
<hr />
<h3>
Sanitize Input</h3>
Let's try cleaning up an URL sent from a form.<br />
First we confirm that the input data we are
looking for exists.<br />
Then we sanitize the input data using the filter_input() function.<br />
In the example below, the input variable "url" is sent to the PHP page:<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table5" style="width: 100%px;"><tbody>
<tr><td>
<pre><?php
if(!filter_has_var(INPUT_POST, "url"))
{
echo("Input type does not exist");
}
else
{
$url = filter_input(INPUT_POST,
"url", FILTER_SANITIZE_URL);
}
?></pre>
</td></tr>
</tbody></table>
<h4>
Example Explained</h4>
The example above has an input (url) sent to it using the "POST" method:<br />
<ol>
<li>Check if the "url" input of the "POST" type exists</li>
<li>If the input variable exists, sanitize (take away invalid characters)
and store it in the $url variable</li>
</ol>
If the input variable is a string like this
"http://www.W3ååSchøøools.com/", the $url variable after the sanitizing will
look like this:<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table16" style="width: 100%px;"><tbody>
<tr><td>
<pre>http://www.W3Schools.com/</pre>
</td></tr>
</tbody></table>
<br />
<hr />
<h3>
Filter Multiple Inputs</h3>
A form almost always consist of more than one input field. To avoid calling
the filter_var or filter_input functions over and over, we can use the
filter_var_array or the filter_input_array functions.<br />
<br />
In this example we use the filter_input_array() function to filter three GET
variables. The received GET variables is a name, an age and an e-mail address:<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table1" style="width: 100%px;"><tbody>
<tr><td>
<pre><?php
$filters = array
(
"name" => array
(
"filter"=>FILTER_SANITIZE_STRING
),
"age" => array
(
"filter"=>FILTER_VALIDATE_INT,
"options"=>array
(
"min_range"=>1,
"max_range"=>120
)
),
"email"=> FILTER_VALIDATE_EMAIL,
);</pre>
<pre>$result = filter_input_array(INPUT_GET, $filters);</pre>
<pre>if (!$result["age"])
{
echo("Age must be a number between 1 and 120.<br />");
}
elseif(!$result["email"])
{
echo("E-Mail is not valid.<br />");
}
else
{
echo("User input is valid");
}
?></pre>
</td></tr>
</tbody></table>
<h4>
Example Explained</h4>
The example above has three inputs (name, age and email) sent to it using the "GET" method:<br />
<ol>
<li>Set an array containing the name of input variables and the filters used
on the specified input variables</li>
<li>Call the filter_input_array() function with the GET input variables and
the array we just set</li>
<li>Check the "age" and "email" variables in the $result variable for
invalid inputs. (If any of the input variables are invalid, that input
variable will be FALSE after the filter_input_array() function)</li>
</ol>
The second parameter of the filter_input_array() function can be an array or
a single filter ID.<br />
If the parameter is a single filter ID all values in the input array are
filtered by the specified filter.<br />
If the parameter is an array it must follow these rules:<br />
<ul>
<li>Must be an associative array containing an input variable as an array key
(like the "age" input variable)</li>
<li>The array value must be a filter ID or an array specifying the
filter, flags and options</li>
</ul>
<hr />
<h3>
Using Filter Callback</h3>
It is possible to call a user defined function and use it as a filter using
the FILTER_CALLBACK filter. This way, we have full control of the data
filtering.<br />
<br />
You can create your own user defined function or use an existing PHP function<br />
The function you wish to use to filter is specified the same way as an option
is specified. In an associative array with the name "options"<br />
<br />
In the example below, we use a user created function to convert all "_"
to whitespaces:<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table8" style="width: 100%px;"><tbody>
<tr><td>
<pre><?php
function convertSpace($string)
{
return str_replace("_", " ", $string);
}
$string = "Peter_is_a_great_guy!";
echo filter_var($string, FILTER_CALLBACK,
array("options"=>"convertSpace"));
?></pre>
</td></tr>
</tbody></table>
<br />
The result from the code above should look like this:<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table17" style="width: 100%px;"><tbody>
<tr><td>
<pre>Peter is a great guy!</pre>
</td></tr>
</tbody></table>
<h4>
Example Explained</h4>
The example above converts all "_" to whitespaces:<br />
<ol>
<li>Create a function to replace "_" to whitespaces</li>
<li>Call the filter_var() function with the FILTER_CALLBACK filter and an
array containing our function</li>
</ol>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-357226456970214079.post-53926243047245083002023-07-29T10:21:00.015+05:302023-07-29T10:21:55.384+05:30PHP23-PHP Exception Handling<div class="intro">
Exceptions are used to change the normal flow of a script if a
specified error occurs</div>
<hr />
<h3>
What is an Exception</h3>
With PHP 5 came a new object oriented way of dealing with errors.<br />
Exception handling is used to change the normal flow of the code execution if
a specified error (exceptional) condition occurs. This condition is called an
exception.<br />
<br />
This is what normally happens when an exception is triggered:<br />
<ul>
<li>The current code state is saved</li>
<li>The code execution will switch to a predefined (custom) exception
handler function</li>
<li>Depending on the situation, the handler may then resume the execution
from the saved code state, terminate the script execution or continue the
script from a different location in the code</li>
</ul>
We will show different error handling methods:<br />
<ul>
<li>Basic use of Exceptions</li>
<li>Creating a custom exception handler</li>
<li>Multiple exceptions</li>
<li>Re-throwing an exception</li>
<li>Setting a top level exception handler</li>
</ul>
<b>Note:</b> Exceptions should only be used with error conditions, and should not be used
to jump to another place in the code at a specified point.<br />
<hr />
<h3>
Basic Use of Exceptions</h3>
When an exception is thrown, the code following it will not be executed, and
PHP will try to find the matching "catch" block.<br />
<br />
If an exception is not caught, a fatal error will be issued with an "Uncaught
Exception" message.<br />
Lets try to throw an exception without catching it:<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table42" style="width: 100%px;"><tbody>
<tr><td>
<pre><?php
//create function with an exception
function checkNum($number)
{
if($number>1)
{
throw new Exception("Value must be 1 or below");
}
return true;
}
//trigger exception
checkNum(2);
?></pre>
</td></tr>
</tbody></table>
<br />
The code above will get an error like this:<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table43" style="width: 100%px;"><tbody>
<tr><td>
<pre><b>Fatal error</b>: Uncaught exception 'Exception'
with message 'Value must be 1 or below' in C:\webfolder\test.php:6
Stack trace: #0 C:\webfolder\test.php(12):
checkNum(28) #1 {main} thrown in <b>C:\webfolder\test.php</b> on line <b>6</b></pre>
</td></tr>
</tbody></table>
<h3>
Try, throw and catch</h3>
To avoid the error from the example above, we need to create the proper code
to handle an exception. <br />
Proper exception code should include:<br />
<ol>
<li>Try - A function using an exception should be in a "try" block. If the
exception does not trigger, the code will continue as normal. However if the
exception triggers, an exception is "thrown"</li>
<li>Throw - This is how you trigger an exception. Each "throw" must have at
least one "catch"</li>
<li>Catch - A "catch" block retrieves an exception and creates an object
containing the exception information</li>
</ol>
Lets try to trigger an exception with valid code:<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table15" style="width: 100%px;"><tbody>
<tr><td>
<pre><?php
//create function with an exception
function checkNum($number)
{
if($number>1)
{
throw new Exception("Value must be 1 or below");
}
return true;
}
//trigger exception in a "try" block
try
{
checkNum(2);
//If the exception is thrown, this text will not be shown
echo 'If you see this, the number is 1 or below';
}
//catch exception
catch(Exception $e)
{
echo 'Message: ' .$e->getMessage();
}
?></pre>
</td></tr>
</tbody></table>
<br />
The code above will get an error like this:<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table14" style="width: 100%px;"><tbody>
<tr><td>
<pre>Message: Value must be 1 or below</pre>
</td></tr>
</tbody></table>
<h4>
Example explained:</h4>
The code above throws an exception and catches it:<br />
<ol>
<li>The checkNum() function is created. It checks if a number is greater
than 1. If it is, an exception is thrown</li>
<li>The checkNum() function is called in a "try" block</li>
<li>The exception within the checkNum() function is thrown</li>
<li>The "catch" block retrives the exception and creates an object ($e)
containing the exception information</li>
<li>The error message from the exception is echoed by calling $e->getMessage()
from the exception object</li>
</ol>
However, one way to get around the "every throw must have a catch" rule is to
set a top level exception handler to handle errors that slip through.<br />
<hr />
<h3>
Creating a Custom Exception Class</h3>
Creating a custom exception handler is quite simple. We simply create a special
class with functions that can be called when an exception occurs in PHP. The
class must be an extension of the exception class.<br />
The custom exception class inherits the properties from PHP's
exception class and you can add custom functions to it.<br />
<br />
Lets create an exception class:<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table24" style="width: 100%px;">
<tbody>
<tr>
<td>
<pre><?php
class customException extends Exception
{
public function errorMessage()
{
//error message
$errorMsg = 'Error on line '.$this->getLine().' in '.$this->getFile()
.': <b>'.$this->getMessage().'</b> is not a valid E-Mail address';
return $errorMsg;
}
}</pre>
<pre>$email = "someone@example...com";</pre>
<pre>try
{
//check if
if(filter_var($email, FILTER_VALIDATE_EMAIL) === FALSE)
{
//throw exception if email is not valid
throw new customException($email);
}
}</pre>
<pre>catch (customException $e)
{
//display custom message
echo $e->errorMessage();
}
?></pre>
</td>
</tr>
</tbody></table>
<br />
The new class is a copy of the old exception class with an addition of the
errorMessage() function. Since it is a copy of the old class, and it inherits
the properties and methods from the old class, we can use the exception class
methods like getLine() and getFile() and getMessage().<br />
<h4>
Example explained:</h4>
The code above throws an exception and catches it with a custom exception
class:<br />
<ol>
<li>The customException() class is created as an extension of the old
exception class. This way it inherits all methods and properties from the
old exception class</li>
<li>The errorMessage() function is created. This function returns an error
message if an e-mail address is invalid</li>
<li>The $email variable is set to a string that is not a valid e-mail
address</li>
<li>The "try" block is executed and an exception is thrown since
the e-mail address is invalid</li>
<li>The "catch" block catches the exception and displays the error message</li>
</ol>
<hr />
<h3>
Multiple Exceptions</h3>
It is possible for a script to use multiple exceptions to check for multiple
conditions.<br />
It is possible to use several if..else blocks, a switch, or nest multiple
exceptions. These exceptions can use different exception classes and return
different error messages:<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table51" style="width: 100%px;">
<tbody>
<tr>
<td>
<pre><?php
class customException extends Exception
{
public function errorMessage()
{
//error message
$errorMsg = 'Error on line '.$this->getLine().' in '.$this->getFile()
.': <b>'.$this->getMessage().'</b> is not a valid E-Mail address';
return $errorMsg;
}
}
$email = "someone@example.com";
try
{
//check if
if(filter_var($email, FILTER_VALIDATE_EMAIL) === FALSE)
{
//throw exception if email is not valid
throw new customException($email);
}
//check for "example" in mail address
if(strpos($email, "example") !== FALSE)
{
throw new Exception("$email is an example e-mail");
}
}
catch (customException $e)
{
echo $e->errorMessage();
}</pre>
<pre>catch(Exception $e)
{
echo $e->getMessage();
}
?></pre>
</td>
</tr>
</tbody></table>
<h4>
Example explained:</h4>
The code above tests two conditions and throws an exception if any of the
conditions are not met:<br />
<ol>
<li>The customException() class is created as an extension of the old
exception class. This way it inherits all methods and properties from the
old exception class</li>
<li>The errorMessage() function is created. This function returns an error
message if an e-mail address is invalid</li>
<li>The $email variable is set to a string that is a valid e-mail
address, but contains the string "example"</li>
<li>The "try" block is executed and an exception is not thrown on
the first condition</li>
<li>The second condition triggers an exception since the e-mail contains the
string "example"</li>
<li>The "catch" block catches the exception and displays the
correct error message</li>
</ol>
If there was no customException catch, only the base exception catch, the
exception would be handled there<br />
<hr />
<h3>
Re-throwing Exceptions</h3>
Sometimes, when an exception is thrown, you may wish to handle it
differently than the standard way. It is possible to throw an exception a second
time within a "catch" block.<br />
<br />
A script should hide system errors from users. System errors may be important
for the coder, but is of no interest to the user. To make things easier for the
user you can re-throw the exception with a user friendly message:<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table52" style="width: 100%px;">
<tbody>
<tr>
<td>
<pre><?php
class customException extends Exception
{
public function errorMessage()
{
//error message
$errorMsg = $this->getMessage().' is not a valid E-Mail address.';
return $errorMsg;
}
}</pre>
<pre>$email = "someone@example.com";</pre>
<pre>try
{
try
{
//check for "example" in mail address
if(strpos($email, "example") !== FALSE)
{
//throw exception if email is not valid
throw new Exception($email);
}
}
catch(Exception $e)
{
//re-throw exception
throw new customException($email);
}
}</pre>
<pre>catch (customException $e)
{
//display custom message
echo $e->errorMessage();
}
?></pre>
</td>
</tr>
</tbody></table>
<h4>
Example explained:</h4>
The code above tests if the email-address contains the string "example" in
it, if it does, the exception is re-thrown:<br />
<ol>
<li>The customException() class is created as an extension of the old
exception class. This way it inherits all methods and properties from the
old exception class</li>
<li>The errorMessage() function is created. This function returns an error
message if an e-mail address is invalid</li>
<li>The $email variable is set to a string that is a valid e-mail
address, but contains the string "example"</li>
<li>The "try" block contains another "try" block to make it
possible to re-throw the exception</li>
<li>The exception is triggered since the e-mail contains the string
"example"</li>
<li>The "catch" block catches the exception and re-throws a "customException"</li>
<li>The "customException" is caught and displays an error message</li>
</ol>
If the exception is not caught in its current "try" block, it will search for a catch block on "higher levels".<br />
<hr />
<h3>
Set a Top Level Exception Handler</h3>
The set_exception_handler() function sets a user-defined function to handle all
uncaught exceptions.<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table53" style="width: 100%px;">
<tbody>
<tr>
<td>
<pre><?php
function myException($exception)
{
echo "<b>Exception:</b> " , $exception->getMessage();
}</pre>
<pre>set_exception_handler('myException');</pre>
<pre>throw new Exception('Uncaught Exception occurred');
?></pre>
</td>
</tr>
</tbody></table>
<br />
The output of the code above should be something like this:<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table54" style="width: 100%px;">
<tbody>
<tr>
<td>
<pre><b>Exception:</b> Uncaught Exception occurred</pre>
</td>
</tr>
</tbody></table>
<br />
In the code above there was no "catch" block. Instead, the top level
exception handler triggered. This function should be used to catch uncaught
exceptions.<br />
<br />
<hr />
<h3>
Rules for exceptions</h3>
<ul>
<li>Code may be surrounded in a try block, to help catch potential
exceptions</li>
<li>Each try block or "throw" must have at least one corresponding catch
block</li>
<li>Multiple catch blocks can be used to catch different classes of
exceptions</li>
<li>Exceptions can be thrown (or re-thrown) in a catch block within a try
block</li>
</ul>
A simple rule: If you throw something, you have to catch it.Unknownnoreply@blogger.comtag:blogger.com,1999:blog-357226456970214079.post-14250366612004193352023-07-29T10:21:00.014+05:302023-07-29T10:21:53.412+05:30PHP22-PHP Error Handling<div class="intro">
The default error handling in PHP is very simple. An error message with filename, line
number and a message describing the error is sent to the browser.</div>
<hr />
<h3>
PHP Error Handling</h3>
When creating scripts and web applications, error handling is an important
part. If your code lacks error checking code, your program may look very
unprofessional and you may be open to security risks.<br />
This tutorial contains some
of the most common error checking methods in PHP.<br />
We will show different error handling methods:<br />
<ul>
<li>Simple "die()" statements</li>
<li>Custom errors and error triggers</li>
<li>Error reporting</li>
</ul>
<hr />
<h3>
Basic Error Handling: Using the die() function</h3>
The first example shows a simple script that opens a text file:<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table12" style="width: 100%px;"><tbody>
<tr><td>
<pre><?php
$file=fopen("welcome.txt","r");
?></pre>
</td></tr>
</tbody></table>
<br />
If the file does not exist you might get an error like this:<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table13" style="width: 100%px;"><tbody>
<tr><td>
<pre><b>Warning</b>: fopen(welcome.txt) [function.fopen]: failed to open stream:
No such file or directory in <b>C:\webfolder\test.php</b> on line <b>2</b></pre>
</td></tr>
</tbody></table>
<br />
To avoid that the user gets an error message like the one above, we test if
the file exist before we try to access it:<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table15" style="width: 100%px;"><tbody>
<tr><td>
<pre><?php
if(!file_exists("welcome.txt"))
{
die("File not found");
}
else
{
$file=fopen("welcome.txt","r");
}
?></pre>
</td></tr>
</tbody></table>
<br />
Now if the file does not exist you get an error like this:<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table14" style="width: 100%px;"><tbody>
<tr><td>
<pre>File not found</pre>
</td></tr>
</tbody></table>
<br />
The code above is more efficient than the earlier code, because it
uses a simple error handling mechanism to stop the script after the error.<br />
However, simply stopping the script is not always the right way to go. Let's take a
look at alternative PHP functions for handling errors.<br />
<hr />
<h3>
Creating a Custom Error Handler</h3>
Creating a custom error handler is quite simple. We simply create a special
function that can be called when an error occurs in PHP.<br />
This function must be able to handle a minimum of two parameters (error
level and error message) but can accept up to five parameters (optionally: file,
line-number, and the error context): <br />
<h4>
Syntax</h4>
<table border="1" cellspacing="0" class="ex" id="table21" style="width: 100%px;">
<tbody>
<tr>
<td>
<pre>error_function(error_level,error_message,
error_file,error_line,error_context)</pre>
</td>
</tr>
</tbody></table>
<table border="1" cellpadding="3" cellspacing="0" class="ex" id="table22" style="width: 100%px;">
<tbody>
<tr>
<th align="left" valign="top" width="20%">Parameter</th>
<th align="left" valign="top" width="80%">Description</th>
</tr>
<tr>
<td valign="top">error_level</td>
<td valign="top">Required. Specifies the error report level for the
user-defined error. Must be a value number. See table below for possible
error report levels</td>
</tr>
<tr>
<td valign="top">error_message</td>
<td valign="top">Required. Specifies the error message for the
user-defined error</td>
</tr>
<tr>
<td valign="top">error_file</td>
<td valign="top">Optional. Specifies the filename in which the error
occurred</td>
</tr>
<tr>
<td valign="top">error_line</td>
<td valign="top">Optional. Specifies the line number in which the error
occurred</td>
</tr>
<tr>
<td valign="top">error_context</td>
<td valign="top">Optional. Specifies an array containing every variable,
and their values, in use when the error occurred</td>
</tr>
</tbody></table>
<h3>
Error Report levels</h3>
These error report levels are the different types of error the user-defined
error handler can be used for:<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table23" style="width: 100%px;">
<tbody>
<tr>
<th align="left" width="5%">Value</th>
<th align="left" width="30%">Constant</th>
<th align="left" width="65%">Description</th>
</tr>
<tr>
<td valign="top">2</td>
<td valign="top">E_WARNING</td>
<td valign="top">Non-fatal run-time errors. Execution of the script is not
halted</td>
</tr>
<tr>
<td valign="top">8</td>
<td valign="top">E_NOTICE</td>
<td valign="top">Run-time notices. The script found something that might be
an error, but could also happen when running a script normally</td>
</tr>
<tr>
<td valign="top">256</td>
<td valign="top">E_USER_ERROR</td>
<td valign="top">Fatal user-generated error. This is like an E_ERROR set by
the programmer using the PHP function trigger_error()</td>
</tr>
<tr>
<td valign="top">512</td>
<td valign="top">E_USER_WARNING</td>
<td valign="top">Non-fatal user-generated warning. This is like an E_WARNING
set by the programmer using the PHP function trigger_error()</td>
</tr>
<tr>
<td valign="top">1024</td>
<td valign="top">E_USER_NOTICE</td>
<td valign="top">User-generated notice. This is like an E_NOTICE set by the
programmer using the PHP function trigger_error()</td>
</tr>
<tr>
<td valign="top">4096</td>
<td valign="top">E_RECOVERABLE_ERROR</td>
<td valign="top">Catchable fatal error. This is like an E_ERROR but can be
caught by a user defined handle (see also set_error_handler())</td>
</tr>
<tr>
<td valign="top">8191</td>
<td valign="top">E_ALL</td>
<td valign="top">All errors and warnings, except level E_STRICT (E_STRICT
will be part of E_ALL as of PHP 6.0)</td>
</tr>
</tbody></table>
<br />
Now lets create a function to handle errors:<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table24" style="width: 100%px;">
<tbody>
<tr>
<td>
<pre>function customError($errno, $errstr)
{
echo "<b>Error:</b> [$errno] $errstr<br />";
echo "Ending Script";
die();
}</pre>
</td>
</tr>
</tbody></table>
<br />
The code above is a simple error handling function. When it is triggered, it
gets the error level and an error message. It then outputs the error level and
message and terminates the script.<br />
Now that we have created an error handling function we need to decide when it
should be triggered.<br />
<hr />
<h3>
Set Error Handler</h3>
The default error handler for PHP is the built in error handler. We are
going to make the function above the default error handler for the duration of
the script.<br />
It is possible to change the error handler to apply for only some errors,
that way the script can handle different errors in different ways. However, in
this example we are going to use our custom error handler for all errors:<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table25" style="width: 100%px;">
<tbody>
<tr>
<td>
<pre>set_error_handler("customError");</pre>
</td>
</tr>
</tbody></table>
<br />
Since we want our custom function to handle all errors, the set_error_handler()
only needed one parameter, a second parameter could be added to specify an error
level.<br />
<h4>
Example</h4>
Testing the error handler by trying to output variable that does not exist:<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table26" style="width: 100%px;">
<tbody>
<tr>
<td>
<pre><?php
//error handler function
function customError($errno, $errstr)
{
echo "<b>Error:</b> [$errno] $errstr";
}</pre>
<pre>//set error handler
set_error_handler("customError");</pre>
<pre>//trigger error
echo($test);
?></pre>
</td>
</tr>
</tbody></table>
<br />
The output of the code above should be something like this:<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table27" style="width: 100%px;">
<tbody>
<tr>
<td>
<pre><b>Error:</b> [8] Undefined variable: test</pre>
</td>
</tr>
</tbody></table>
<br />
<hr />
<h3>
Trigger an Error</h3>
In a script where users can input data it is useful to trigger errors when an
illegal input occurs. In PHP, this is done by the trigger_error() function.<br />
<h4>
Example</h4>
In this example an error occurs if the "test" variable is bigger than "1":<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table32" style="width: 100%px;">
<tbody>
<tr>
<td>
<pre><?php
$test=2;
if ($test>1)
{
trigger_error("Value must be 1 or below");
}
?></pre>
</td>
</tr>
</tbody></table>
<br />
The output of the code above should be something like this:<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table33" style="width: 100%px;">
<tbody>
<tr>
<td>
<pre><b>Notice</b>: Value must be 1 or below
in <b>C:\webfolder\test.php</b> on line <b>6</b></pre>
</td>
</tr>
</tbody></table>
<br />
An error can be triggered anywhere you wish in a script, and by adding a
second parameter, you can specify what error level is triggered.<br />
Possible error types:<br />
<ul>
<li>E_USER_ERROR - Fatal user-generated run-time error. Errors that can not
be recovered from. Execution of the script is halted
</li>
<li>E_USER_WARNING - Non-fatal user-generated run-time warning. Execution of
the script is not halted
</li>
<li>E_USER_NOTICE - Default. User-generated run-time notice. The script
found something that might be an error, but could also happen when running a
script normally </li>
</ul>
<h4>
Example</h4>
In this example an E_USER_WARNING occurs if the "test" variable is bigger
than "1". If an E_USER_WARNING occurs we will use our custom error handler
and end the script:<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table36" style="width: 100%px;">
<tbody>
<tr>
<td>
<pre><?php
//error handler function
function customError($errno, $errstr)
{
echo "<b>Error:</b> [$errno] $errstr<br />";
echo "Ending Script";
die();
}</pre>
<pre>//set error handler
set_error_handler("customError",E_USER_WARNING);</pre>
<pre>//trigger error
$test=2;
if ($test>1)
{
trigger_error("Value must be 1 or below",E_USER_WARNING);
}
?></pre>
<pre> </pre>
</td>
</tr>
</tbody></table>
<br />
The output of the code above should be something like this:<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table37" style="width: 100%px;">
<tbody>
<tr>
<td>
<pre><b>Error:</b> [512] Value must be 1 or below
Ending Script</pre>
</td>
</tr>
</tbody></table>
<br />
Now that we have learned to create our own errors and how to trigger them,
lets take a look at error logging.<br />
<hr />
<h3>
Error Logging</h3>
By default, PHP sends an error log to the servers logging system or a file,
depending on how the error_log configuration is set in the php.ini file. By
using the error_log() function you can send error logs to a specified file or a
remote destination.<br />
Sending errors messages to yourself by e-mail can be a good way of getting
notified of specific errors.<br />
<h3>
Send an Error Message by E-Mail</h3>
In the example below we will send an e-mail with an error message and end the
script, if a specific error occurs:<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table40" style="width: 100%px;">
<tbody>
<tr>
<td>
<pre><?php
//error handler function
function customError($errno, $errstr)
{
echo "<b>Error:</b> [$errno] $errstr<br />";
echo "Webmaster has been notified";
error_log("Error: [$errno] $errstr",1,
"someone@example.com","From: webmaster@example.com");
}</pre>
<pre>//set error handler
set_error_handler("customError",E_USER_WARNING);</pre>
<pre>//trigger error
$test=2;
if ($test>1)
{
trigger_error("Value must be 1 or below",E_USER_WARNING);
}
?></pre>
</td>
</tr>
</tbody></table>
<br />
The output of the code above should be something like this:<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table42" style="width: 100%px;">
<tbody>
<tr>
<td>
<pre><b>Error:</b> [512] Value must be 1 or below
Webmaster has been notified</pre>
</td>
</tr>
</tbody></table>
<br />
And the mail received from the code above looks like this:<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table41" style="width: 100%px;">
<tbody>
<tr>
<td>
<pre>Error: [512] Value must be 1 or below</pre>
</td>
</tr>
</tbody></table>
<br />
This should not be used with all errors. Regular errors should be logged on
the server using the default PHP logging system.Unknownnoreply@blogger.comtag:blogger.com,1999:blog-357226456970214079.post-22552579490801392872023-07-29T10:21:00.013+05:302023-07-29T10:21:51.149+05:30PHP21-PHP Secure E-mails<div class="intro">
There is a weakness in the PHP e-mail script in the previous
chapter.</div>
<hr />
<h3>
PHP E-mail Injections</h3>
First, look at the PHP code from the previous chapter:<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table1" style="width: 100%px;">
<tbody>
<tr>
<td>
<pre><html>
<body></pre>
<pre><?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
{
//send email
$email = $_REQUEST['email'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
mail("someone@example.com", "Subject: $subject",
$message, "From: $email" );
echo "Thank you for using our mail form";
}
else
//if "email" is not filled out, display the form
{
echo "<form method='post' action='mailform.php'>
Email: <input name='email' type='text' /><br />
Subject: <input name='subject' type='text' /><br />
Message:<br />
<textarea name='message' rows='15' cols='40'>
</textarea><br />
<input type='submit' />
</form>";
}
?></pre>
<pre></body>
</html></pre>
</td>
</tr>
</tbody></table>
<br />
The problem with the code above is that unauthorized users can insert data into the
mail headers via the input form.<br />
<br />
What happens if the user adds the following text to the email input field in
the form?<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table4" style="width: 100%px;">
<tbody>
<tr>
<td>
<pre>someone@example.com%0ACc:person2@example.com
%0ABcc:person3@example.com,person3@example.com,
anotherperson4@example.com,person5@example.com
%0ABTo:person6@example.com</pre>
</td>
</tr>
</tbody></table>
<br />
The mail() function puts the text above into the mail headers as usual, and now the
header has an extra Cc:, Bcc:, and To: field. When the user clicks the submit
button, the e-mail will be sent to all of the addresses above!<br />
<hr />
<h3>
PHP Stopping E-mail Injections</h3>
The best way to stop e-mail injections is to validate the input.<br />
The code below is the same as in the previous chapter, but now we have added an input validator
that checks the email field in the form:<br />
<br />
<table border="1" cellspacing="0" class="ex" style="width: 100%px;"><tbody>
<tr><td>
<pre><html>
<body>
<?php
function spamcheck($field)
{
//filter_var() sanitizes the e-mail
//address using FILTER_SANITIZE_EMAIL
$field=filter_var($field, FILTER_SANITIZE_EMAIL);
//filter_var() validates the e-mail
//address using FILTER_VALIDATE_EMAIL
if(filter_var($field, FILTER_VALIDATE_EMAIL))
{
return TRUE;
}
else
{
return FALSE;
}
}</pre>
<pre>if (isset($_REQUEST['email']))
{//if "email" is filled out, proceed</pre>
<pre> //check if the email address is invalid
$mailcheck = spamcheck($_REQUEST['email']);
if ($mailcheck==FALSE)
{
echo "Invalid input";
}
else
{//send email
$email = $_REQUEST['email'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
mail("someone@example.com", "Subject: $subject",
$message, "From: $email" );
echo "Thank you for using our mail form";
}
}
else
{//if "email" is not filled out, display the form
echo "<form method='post' action='mailform.php'>
Email: <input name='email' type='text' /><br />
Subject: <input name='subject' type='text' /><br />
Message:<br />
<textarea name='message' rows='15' cols='40'>
</textarea><br />
<input type='submit' />
</form>";
}
?></pre>
<pre></body>
</html></pre>
</td></tr>
</tbody></table>
<br />
In the code above we use PHP filters to validate input:<br />
<ul>
<li>The FILTER_SANITIZE_EMAIL filter removes all illegal e-mail characters
from a string</li>
<li>The FILTER_VALIDATE_EMAIL filter validates value as an e-mail address</li>
</ul>
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-357226456970214079.post-17792355230927932192023-07-29T10:21:00.012+05:302023-07-29T10:21:49.109+05:30PHP20-PHP Sending E-mails<div class="intro">
PHP allows you to send e-mails directly from a script.</div>
<hr />
<h3>
The PHP mail() Function</h3>
The PHP mail() function is used to send emails from inside a script.<br />
<br />
<b>Syntax</b><br />
<br />
<table border="1" cellspacing="0" class="ex" id="table1" style="width: 100%px;">
<tbody>
<tr>
<td>
<pre>mail(to,subject,message,headers,parameters)</pre>
</td>
</tr>
</tbody></table>
<br />
<table border="1" cellpadding="3" cellspacing="0" class="ex" id="table2" style="width: 100%px;">
<tbody>
<tr>
<th align="left" valign="top" width="20%">Parameter</th>
<th align="left" valign="top" width="80%">Description</th>
</tr>
<tr>
<td valign="top">to</td>
<td valign="top">Required. Specifies
the receiver / receivers of the email</td>
</tr>
<tr>
<td valign="top">subject</td>
<td valign="top">Required. Specifies
the subject of the email. <b>Note:</b> This parameter cannot contain any newline
characters</td>
</tr>
<tr>
<td valign="top">message</td>
<td valign="top">Required. Defines the message to be sent. Each line should
be separated with a LF (\n). Lines should not exceed 70 characters</td>
</tr>
<tr>
<td valign="top">headers</td>
<td valign="top">Optional. Specifies additional headers, like From, Cc, and
Bcc. The additional headers should be separated with a CRLF (\r\n)</td>
</tr>
<tr>
<td valign="top">parameters</td>
<td valign="top">Optional. Specifies an additional parameter to the sendmail program</td>
</tr>
</tbody></table>
<br />
<b>Note:</b> For the mail functions to be available, PHP requires an installed
and working email system. The program to be used is defined by the configuration
settings in the php.ini file. Read more in our <a href="http://www.blogger.com/blogger.g?blogID=357226456970214079">PHP
Mail reference</a>.<br />
<hr />
<h3>
PHP Simple E-Mail</h3>
The simplest way to send an email with PHP is to send a text email.<br />
In the example below we first declare the variables ($to, $subject, $message,
$from, $headers), then we use the variables in the mail() function to send an e-mail:<br />
<br />
<table border="1" cellspacing="0" class="ex" style="width: 100%px;"><tbody>
<tr><td>
<pre><?php</pre>
<pre>$to = "someone@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";</pre>
<pre>?></pre>
</td></tr>
</tbody></table>
<br />
<hr />
<h3>
PHP Mail Form</h3>
With PHP, you can create a feedback-form on your website. The example below
sends a text message to a specified e-mail address:<br />
<br />
<table border="1" cellspacing="0" class="ex" style="width: 100%px;"><tbody>
<tr><td>
<pre><html>
<body></pre>
<pre><?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
{
//send email
$email = $_REQUEST['email'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
mail( "someone@example.com", "Subject: $subject",
$message, "From: $email" );
echo "Thank you for using our mail form";
}
else
//if "email" is not filled out, display the form
{
echo "<form method='post' action='mailform.php'>
Email: <input name='email' type='text' /><br />
Subject: <input name='subject' type='text' /><br />
Message:<br />
<textarea name='message' rows='15' cols='40'>
</textarea><br />
<input type='submit' />
</form>";
}
?></pre>
<pre></body>
</html></pre>
</td></tr>
</tbody></table>
<br />
This is how the example above works:<ul>
<li>First, check if the email input field is filled out</li>
<li>If it is not set (like when the page is
first visited); output the HTML form</li>
<li>If it is set (after the form is filled out);
send the email from the form</li>
<li>When submit is pressed after the form is filled out, the page reloads,
sees that the email input is set, and sends the email</li>
</ul>
<b>Note:</b> This is the simplest way to send e-mail, but it is not
secure. In the next chapter of this tutorial you can read more about vulnerabilities in e-mail
scripts, and how to validate user input to make it more secure.Unknownnoreply@blogger.comtag:blogger.com,1999:blog-357226456970214079.post-65005892176777382882023-07-29T10:21:00.011+05:302023-07-29T10:21:46.950+05:30PHP19-PHP Sessions<div class="intro">
A PHP session variable is used to store information about, or
change settings for a user session. Session variables hold information about one
single user, and are available to all pages in one application.</div>
<hr />
<h3>
PHP Session Variables</h3>
When you are working with an application, you open it, do some changes and
then you close it. This is much like a Session. The computer knows who you are.
It knows when you start the application and when you end. But on the internet
there is one problem: the web server does not know who you are and what you do
because the HTTP address doesn't maintain state.<br />
A PHP session solves this problem by allowing you to store user information
on the server for later use (i.e. username, shopping items, etc). However, session information is temporary and
will be deleted after
the user has left the website. If you need a permanent storage you may want to store the data in a database.<br />
Sessions work by creating a unique id (UID) for each
visitor and store variables based on this UID. The UID is either stored in a
cookie or is propagated in the URL.<br />
<hr />
<h3>
Starting a PHP Session</h3>
Before you can store user information in your PHP session, you must
first start up the session.<br />
<b>Note:</b> The session_start() function must appear BEFORE the <html> tag:<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table6" style="width: 100%px;"><tbody>
<tr><td>
<pre><?php session_start(); ?></pre>
<pre><html>
<body></pre>
<pre></body>
</html></pre>
</td></tr>
</tbody></table>
<br />
The code above will register the user's session with the server, allow you to
start saving user information, and assign a UID
for that user's session.<br />
<hr />
<h3>
Storing a Session Variable</h3>
The correct way to store and retrieve session variables is to use the
PHP $_SESSION variable:<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table7" style="width: 100%px;"><tbody>
<tr><td>
<pre><?php
session_start();
// store session data
$_SESSION['views']=1;
?></pre>
<pre><html>
<body></pre>
<pre><?php
//retrieve session data
echo "Pageviews=". $_SESSION['views'];
?></pre>
<pre></body>
</html></pre>
</td></tr>
</tbody></table>
<br />
Output:<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table8" style="width: 100%px;"><tbody>
<tr><td>
<pre>Pageviews=1</pre>
</td></tr>
</tbody></table>
<br />
In the example below, we create a simple page-views counter. The isset()
function checks if the "views" variable has already been set. If "views" has
been set, we
can increment our counter. If "views" doesn't exist, we create a "views"
variable,
and set it to 1:<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table9" style="width: 100%px;"><tbody>
<tr><td>
<pre><?php
session_start();</pre>
<pre>if(isset($_SESSION['views']))
$_SESSION['views']=$_SESSION['views']+1;
else
$_SESSION['views']=1;
echo "Views=". $_SESSION['views'];
?></pre>
</td></tr>
</tbody></table>
<br />
<hr />
<h3>
Destroying a Session</h3>
If you wish to delete some session data, you can use the unset() or the
session_destroy() function.<br />
The unset() function is used to free the specified session variable:<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table10" style="width: 100%px;"><tbody>
<tr><td>
<pre><?php
unset($_SESSION['views']);
?></pre>
</td></tr>
</tbody></table>
<br />
You can also completely destroy the session by calling the session_destroy() function:<br />
<br />
<table border="1" cellspacing="0" class="ex" id="table11" style="width: 100%px;"><tbody>
<tr><td>
<pre><?php
session_destroy();
?></pre>
</td></tr>
</tbody></table>
<b>Note:</b> session_destroy() will reset your session and you will lose all
your stored session data.Unknownnoreply@blogger.com