    <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:content="http://purl.org/rss/1.0/modules/content/">
     <channel>
        <title>MirageLab :: PHP</title>
        <link>http://www.miragelab.com/</link>
        <description>Lex Informatica</description>
        <dc:language>en-us</dc:language> 
        <dc:creator>SaintEgo</dc:creator> 
        <admin:generatorAgent rdf:resource="http://www.xaraya.org" /> 
        <admin:errorReportsTo rdf:resource="mailto:cdavidkraeft@miragelab.com" /> 
       <sy:updatePeriod>hourly</sy:updatePeriod> 
       <sy:updateFrequency>1</sy:updateFrequency> 
       <docs>http://backend.userland.com/rss</docs>

<!-- show a header for the current publication type -->
        <h2>FAQs</h2>


<a name="titles">
</a>
<div class="xar-mod-head"><span class="xar-mod-title">PHP</span></div>

<table border="0" cellpadding="1" cellspacing="0">
<tr>
    <td valign="top">
        Browse in :
   </td>
   <td valign="top">

                                    <a href="http://www.miragelab.com/faqs/">All</a>

                 &gt;                     <a href="http://www.miragelab.com/faqs/c41/">FAQs</a>

                 &gt;                     PHP<br />
</td>
</tr>
</table>






<ul>
            <li>
                <a href="http://www.miragelab.com/faqs/c42/?theme=rss#34">
                    Ampersand and Passing by Reference</a>
           </li>
            <li>
                <a href="http://www.miragelab.com/faqs/c42/?theme=rss#29">
                    Conversion Specification Type Codes</a>
           </li>
            <li>
                <a href="http://www.miragelab.com/faqs/c42/?theme=rss#28">
                    ECHO, PRINT, PRINTF, and SPRINTF Differences</a>
           </li>
            <li>
                <a href="http://www.miragelab.com/faqs/c42/?theme=rss#30">
                    ISSET() vs. EMPTY()</a>
           </li>
            <li>
                <a href="http://www.miragelab.com/faqs/c42/?theme=rss#41">
                    PHP Image Functions</a>
           </li>
            <li>
                <a href="http://www.miragelab.com/faqs/c42/?theme=rss#32">
                    Regular Expressions (REGEX)</a>
           </li>
            <li>
                <a href="http://www.miragelab.com/faqs/c42/?theme=rss#33">
                    REQUIRE() vs INCLUDE()</a>
           </li>
            <li>
                <a href="http://www.miragelab.com/faqs/c42/?theme=rss#31">
                    User Specified Array Sorting with USORT()</a>
           </li>
</ul>
            <a name="34"></a>
<br />
<a class="xar-title" href="http://www.miragelab.com/faqs/34">Ampersand and Passing by Reference</a>
<p>Occasionally, within function arguments, a variable will be listed with a preceeding ampersand, "&". This specifies the variable as being only a reference to the original (with any changes made to the variable inside the scope of the function being applied to the original value <b>outside</b> the function). In this fashion, the modified variable need not be returned or globalized to see changes made by the function. The function simply refers to the original value, and changes are applied there, all in one shot.</p>
<p><a href="http://www.miragelab.com/faqs/c42/?theme=rss#titles">Back to top</a></p>
            <a name="29"></a>
<br />
<a class="xar-title" href="http://www.miragelab.com/faqs/29">Conversion Specification Type Codes</a>
<p>The following designations are used inside of PRINTF and SPRINTF to indicate the format of the variable displayed:
<li><b>b</b> - translate an integer into a binary value
<li><b>c</b> - translate an integer as a character value
<li><b>d</b> - translate an integer as a decimal number
<li><b>f</b> - translate a double as a floating point number
<li><b>o</b> - translate an integer as an octal value
<li><b>s</b> - translate a string directly
<li><b>x</b> - translate an integer as a hex value (<i>lower case</i>)
<li><b>X</b> - translate an integer as a hex value (<i>upper case</i>)</p>
<p><a href="http://www.miragelab.com/faqs/c42/?theme=rss#titles">Back to top</a></p>
            <a name="28"></a>
<br />
<a class="xar-title" href="http://www.miragelab.com/faqs/28">ECHO, PRINT, PRINTF, and SPRINTF Differences</a>
<p>While both ECHO and PRINT output to the browser, PRINT is a function and provides a return value (0 or 1 depending on whether the function was successful or not).

PRINTF and SPRINTF both use <a href="modules.php?op=modload&name=FAQ&file=index&myfaq=yes&id_cat=1&categories=PHP+Idiosyncracies&parent_id=0#2">Conversion Specification Type Codes</a>. Like ECHO, PRINTF also outputs to the browser, while SPRINTF returns output like PRINT. Both of these functions take an argument for a string to be formatted, followed by a list of arguments specified for placement inside the string (at locations designated by conversion specification codes within the string).

The conversion spec format begins with a "%", followed by an optional apostrophe and padding character, followed by an optional dash, "-", followed by optional width (in characters), followed by a precision indicator (decimal followed by the number of places to display after the decimal), followed by the <a href="modules.php?op=modload&name=FAQ&file=index&myfaq=yes&id_cat=1&categories=PHP+Idiosyncracies&parent_id=0#2">Type Code</a>.</p>
<p><a href="http://www.miragelab.com/faqs/c42/?theme=rss#titles">Back to top</a></p>
            <a name="30"></a>
<br />
<a class="xar-title" href="http://www.miragelab.com/faqs/30">ISSET() vs. EMPTY()</a>
<p>Often, a conditional will be coded such that verifies both that the variable contains a value (<i>ie. not NULL</i>) and that the value is not "0" or blank. To combine both tests into one check, use instead the EMPTY function which checks for actual data in one shot.</p>
<p><a href="http://www.miragelab.com/faqs/c42/?theme=rss#titles">Back to top</a></p>
            <a name="41"></a>
<br />
<a class="xar-title" href="http://www.miragelab.com/faqs/41">PHP Image Functions</a>
<p><li><b>ImageCreate</b>(<i>width, height</i>) returns the result the identifier for a new image having the specified dimensions.
<li><b>ImageColorAllocate</b>(<i>image identifier, 8-bit red, 8-bit green, 8-bit blue</i>) returns an identifier for the specified color to be used within the image.
<li><b>ImageFill</b>(<i>image identifier, starting x pos, starting y pos, color identifier</i>) will fill the image starting at the specified coordinates with the specified color.
<li><b>ImageLine</b>(<i>image identifier, starting x pos, starting y pos, ending x pos, ending y pos, color identifier</i>) draws a line within the image based on the specified arguments.
<li><b>ImageString</b>(<i>image identifier, fontsize, starting x pos, starting y pos, string to add, color identifier</i>) will insert text into the image.

The resulting image can be displayed by calling the file that it is generated from and returning <b>Header("Content-type: image/<i>imagetype</i>")</b> (where <i>imagetype</i> is either png, jpeg, or gif) followed by a call to <b>ImagePNG</b>(<i>image identifier</i>). ImageJPEG() and ImageGIF() may also be used, depending on the desired output format.

Alternatively, the image may be stored as an actual graphic file of the specified type by adding an optional <i>filename</i> argument.

Once completed, the image identifier should be killed so that it does not continue to tie up resources using <b>ImageDestroy</b>(<i>image identifier</i>).

If a base image already exists, it can be used with the following commands to create a new image for modification (as would be the case with buttons): <b>ImageCreateFromPNG</b>(<i>filename</i>), <b>ImageCreateFromJPEG</b>(<i>filename</i>), and <b>ImageCreateFromGIF</b>(<i>filename</i>).</p>
<p><a href="http://www.miragelab.com/faqs/c42/?theme=rss#titles">Back to top</a></p>
            <a name="32"></a>
<br />
<a class="xar-title" href="http://www.miragelab.com/faqs/32">Regular Expressions (REGEX)</a>
<p>Most commonly used in the EREG_REPLACE and EREGI_REPLACE functions, regular expressions find patterns in data. The pattern is determined by the contents of the regular expression. Any part of the expression that is enclosed with square brackets ("[" and "]") will be used as the comparison value.

The following characters specify patterns <b>outside</b> the comparison value:
<li><b>\</b> - escape character
<li><b>^</b> - match at beginning of string
<li><b>$</b> - match at end of string
<li><b>.</b> - match any character except newline
<li><b>|</b> - read as "<b>OR</b>"
<li><b>(</b> - begins an OR pattern
<li><b>)</b> - terminates an OR pattern
<li><b>*</b> - repeat if able
<li><b>+</b> - repeat at least once

<b>Inside</b> the comparison value, the following special characters may be used:
<li><b>\</b> - escape character
<li><b>^</b> - NOT (when used as first character only)
<li><b>-</b> - specifies a range of characters

The following shortcuts may also be used inside regular expressions:
<li><b>[[:alnum:]]</b> - alphanumeric characters
<li><b>[[:alpha:]]</b> - alpha only characters
<li><b>[[:lower:]]</b> - lowercase letters
<li><b>[[:upper:]]</b> - uppercase letters
<li><b>[[:digit:]]</b> - decimal numbers
<li><b>[[:xdigit:]]</b> - hex numbers
<li><b>[[:punct:]]</b> - punctuation
<li><b>[[:blank:]]</b> - tabs and spaces
<li><b>[[:space:]]</b> - whitespace characters
<li><b>[[:cntrl:]]</b> - control characters
<li><b>[[:print:]]</b> - all printable characters
<li><b>[[:graph:]]</b> - all printable characters (except space)</p>
<p><a href="http://www.miragelab.com/faqs/c42/?theme=rss#titles">Back to top</a></p>
            <a name="33"></a>
<br />
<a class="xar-title" href="http://www.miragelab.com/faqs/33">REQUIRE() vs INCLUDE()</a>
<p>INCLUDE is run every time the statement is executed, but REQUIRE will run only once, regardless of whether or not the statement is executed (<i>thus making it pointless to nest REQUIRE in a conditional</i>). Included files (using INCLUDE only) may also use a return value (the same as a function). However, due to the more simplistic way that REQUIRE works, it does execute faster than INCLUDE.</p>
<p><a href="http://www.miragelab.com/faqs/c42/?theme=rss#titles">Back to top</a></p>
            <a name="31"></a>
<br />
<a class="xar-title" href="http://www.miragelab.com/faqs/31">User Specified Array Sorting with USORT()</a>
<p>Should a developer require a method to sort an array in a non-standard fashion, USORT comes in very handy. It takes two arguments: the array to be sorted, and the name of the function used to sort. This function is typically defined by the developer so that it takes two arguments, current and next array value. The return code instructs USORT as to whether the two values passed are equal (0), or whether the first value should come before or after the comparison value (1 or -1, respectively).</p>
<p><a href="http://www.miragelab.com/faqs/c42/?theme=rss#titles">Back to top</a></p>
<div class="xar-align-center">

    <div></div>
</div>
<ul style="margin:0;padding:0;">
            <li style="display:inline;padding:0 .5em;">
                <a href="http://www.miragelab.com/faqs/map/">
                    View Article Map</a>
           </li>
</ul>


   </channel>
</rss>
