<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>

<channel>
	<title>Mach13</title>
	<atom:link href="http://mach13.com/feed" rel="self" type="application/rss+xml" />
	<link>http://mach13.com</link>
	<description>Internet Solutions</description>
	<pubDate>Fri, 17 Apr 2009 20:54:45 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Loose and multiline parse_ini_file function in Php</title>
		<link>http://mach13.com/loose-and-multiline-parse_ini_file-function-in-php</link>
		<comments>http://mach13.com/loose-and-multiline-parse_ini_file-function-in-php#comments</comments>
		<pubDate>Thu, 29 Jan 2009 21:32:19 +0000</pubDate>
		<dc:creator>Jean-Jacques Guegan</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Add new tag]]></category>

		<category><![CDATA[comments]]></category>

		<guid isPermaLink="false">http://mach13.com/?p=64</guid>
		<description><![CDATA[Some time ago, I was looking for a multiline parse_ini_file function to use in one of my scripts.
I found nothing on the web apart from other people looking for the same thing. So I decided to do it myself...

Compared with the stock parse_ini_file function, what I wanted was a "raw mode" function - i.e. with [...]]]></description>
			<content:encoded><![CDATA[<p>Some time ago, I was looking for a <b>multiline parse_ini_file function</b> to use in one of my scripts.</p>
<p>I found nothing on the web apart from other people looking for the same thing. So I decided to do it myself...<br />
<span id="more-64"></span><br />
Compared with the stock parse_ini_file function, what I wanted was a <b>"raw mode"</b> function - i.e. with no interpretation of value content - and the use of <b>sections</b>. The Php function does not enable these modes by default but I often set them because they are necessary. Therefore my function, parseIniFile, uses these modes.</p>
<p>The ini file syntax supported by parseIniFile is :</p>
<pre>
[Section name]

key = value value value    ; comments
"key key" = "value value value"
key = "value value value
         value value value"
</pre>
<p>&nbsp;</p>
<ul>
<li>Almost any character is accepted as Key (including spaces, "*" etc) or Value - you can even use "=" inside the value if quotes are used to enclose it.</li>
<li>You have to put section name inside square brakets.</li>
<li>A multiline value must be inside quotes.</li>
<li>Comments are properly processed - i.e. a ";" inside a key or a value won't mean the beginning of a comment.</li>
</ul>
<p>&nbsp;</p>
<p>Here is the "magic" function (only 400 bytes):</p>
<pre class="php">&nbsp;
&nbsp;
  <span style="color: #A0A0A0; font-weight: bold;">function</span> parseIniFile<span style="color: #808080;">&#40;</span><span style="color: #308ecf;">$iIniFile</span><span style="color: #808080;">&#41;</span>
    <span style="color: #808080;">&#123;</span>
    <span style="color: #308ecf;">$aResult</span>  =
    <span style="color: #308ecf;">$aMatches</span> = <a href="http://www.php.net/array"><span style="color: #808080;">array</span></a><span style="color: #808080;">&#40;</span><span style="color: #808080;">&#41;</span>;
&nbsp;
    <span style="color: #308ecf;">$a</span> = &amp;<span style="color: #308ecf;">$aResult</span>;
    <span style="color: #308ecf;">$s</span> = <span style="color: #FFC000;">'<span style="color: #308ecf; font-weight: bold;">\s</span>*([[:alnum:]_<span style="color: #308ecf; font-weight: bold;">\-</span> <span style="color: #308ecf; font-weight: bold;">\*</span>]+?)<span style="color: #308ecf; font-weight: bold;">\s</span>*'</span>;
&nbsp;
    <a href="http://www.php.net/preg_match_all"><span style="color: #808080;">preg_match_all</span></a><span style="color: #808080;">&#40;</span><span style="color: #FFC000;">'#^<span style="color: #308ecf; font-weight: bold;">\s</span>*((<span style="color: #308ecf; font-weight: bold;">\[</span>'</span>.<span style="color: #308ecf;">$s</span>.<span style="color: #FFC000;">'<span style="color: #308ecf; font-weight: bold;">\]</span>)|((&quot;?)'</span>.<span style="color: #308ecf;">$s</span>.<span style="color: #FFC000;">'<span style="color: #308ecf; font-weight: bold;">\\</span>5<span style="color: #308ecf; font-weight: bold;">\s</span>*=<span style="color: #308ecf; font-weight: bold;">\s</span>*(&quot;?)(.*?)<span style="color: #308ecf; font-weight: bold;">\\</span>7))<span style="color: #308ecf; font-weight: bold;">\s</span>*(;[^<span style="color: #308ecf; font-weight: bold;">\n</span>]*?)?$#ms'</span>, @<a href="http://www.php.net/file_get_contents"><span style="color: #808080;">file_get_contents</span></a><span style="color: #808080;">&#40;</span><span style="color: #308ecf;">$iIniFile</span><span style="color: #808080;">&#41;</span>, <span style="color: #308ecf;">$aMatches</span>, PREG_SET_ORDER<span style="color: #808080;">&#41;</span>;
&nbsp;
    <span style="color: #808080;">foreach</span> <span style="color: #808080;">&#40;</span><span style="color: #308ecf;">$aMatches</span> <span style="color: #808080;">as</span> <span style="color: #308ecf;">$aMatch</span><span style="color: #808080;">&#41;</span>
      <span style="color: #808080;">&#123;</span>
      <span style="color: #808080;">if</span> <span style="color: #808080;">&#40;</span><a href="http://www.php.net/empty"><span style="color: #808080;">empty</span></a><span style="color: #808080;">&#40;</span><span style="color: #308ecf;">$aMatch</span><span style="color: #808080;">&#91;</span><span style="color: #FFC000;">2</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span>
              <span style="color: #308ecf;">$a</span> <span style="color: #808080;">&#91;</span><span style="color: #308ecf;">$aMatch</span><span style="color: #808080;">&#91;</span><span style="color: #FFC000;">6</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#93;</span> = <span style="color: #308ecf;">$aMatch</span><span style="color: #808080;">&#91;</span><span style="color: #FFC000;">8</span><span style="color: #808080;">&#93;</span>;
        <span style="color: #808080;">else</span>  <span style="color: #308ecf;">$a</span> = &amp;<span style="color: #308ecf;">$aResult</span> <span style="color: #808080;">&#91;</span><span style="color: #308ecf;">$aMatch</span><span style="color: #808080;">&#91;</span><span style="color: #FFC000;">3</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#93;</span>;
      <span style="color: #808080;">&#125;</span>
&nbsp;
    <span style="color: #808080;">return</span> <span style="color: #308ecf;">$aResult</span>;
    <span style="color: #808080;">&#125;</span>
&nbsp;</pre>
<p>Just include the function <b>parseIniFile</b> in your scripts and use it as a replacement for the standard Php function <b>parse_ini_file</b>.</p>
<p>The code is available <a href="/parseIniFile.zip">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://mach13.com/loose-and-multiline-parse_ini_file-function-in-php/feed</wfw:commentRss>
		</item>
		<item>
		<title>Smart headers with Text To Img</title>
		<link>http://mach13.com/smart-headers-with-text-to-img</link>
		<comments>http://mach13.com/smart-headers-with-text-to-img#comments</comments>
		<pubDate>Wed, 28 Jan 2009 10:36:54 +0000</pubDate>
		<dc:creator>Jean-Jacques Guegan</dc:creator>
		
		<category><![CDATA[Web Design]]></category>

		<guid isPermaLink="false">http://mach13.com/?p=53</guid>
		<description><![CDATA[TextToImg.com offers an easy and convenient way to put graphic headers on your website using smarter fonts.
Like this :

or this :



Without TextToImg, when you want to add graphic text with smarter fonts, you have to open your favorite graphic editor and create an image for each header - and reopen it again and again if [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://TextToImg.com" target="_blank"><b>TextToImg.com</b></a> offers an easy and convenient way to put graphic headers on your website using <a href="http://texttoimg.com/fonts.php" target="_blank">smarter fonts</a>.</p>
<p>Like this :<br><br />
<img src="http://texttoimg.com/Shop_antagea_24_FF99CC_000000_CC0000_1.png" width="50" height="43" alt="" /><br />
or this :<br><br />
<img src="http://texttoimg.com/I - Everything you need to know about me_black chancery_18_CC9900_000000.png" width="405" height="31" alt="" /><br />
<span id="more-53"></span><br />
<br><br />
Without TextToImg, when you want to add graphic text with smarter fonts, you have to open your favorite graphic editor and create an image for each header - and reopen it again and again if you decide to change anything in your header text...</p>
<p>Most designers just abandon graphic header texts because they are so tedious to maintain.</p>
<p>With <a href="http://TextToImg.com" target="_blank"><b>TextToImg</b></a>, just call the image and it will be displayed - the URL defines everything :</p>
<p><img src="http://texttoimg.com/Products_geo (oblique)_16_0066FF_000000_FFFFFF_1.png" width="82" height="19" alt="" /><br><br />
<a href="http://texttoimg.com/Products_geo&nbsp;(oblique)_16_0066FF_000000_FFFFFF_1.png" target="_blank"><code>http://texttoimg.com/Products_geo&nbsp;(oblique)_16_0066FF_000000_FFFFFF_1.png</code></a></p>
<p><br><br />
Updates are easy.   When you want change your graphic text, just modify the TextToImg URL in your HTML.<br />
<br><br />
What's more TextToImg is completely free with no registration !</p>
]]></content:encoded>
			<wfw:commentRss>http://mach13.com/smart-headers-with-text-to-img/feed</wfw:commentRss>
		</item>
		<item>
		<title>Improve your external links with Favicons</title>
		<link>http://mach13.com/improve-your-external-links-with-favicons</link>
		<comments>http://mach13.com/improve-your-external-links-with-favicons#comments</comments>
		<pubDate>Sun, 20 Nov 2005 08:41:08 +0000</pubDate>
		<dc:creator>Jean-Jacques Guegan</dc:creator>
		
		<category><![CDATA[Web Design]]></category>

		<guid isPermaLink="false">http://mach13.com/?p=19</guid>
		<description><![CDATA[Put some style into your links.
By including this PHP script on your site, you can call the FaviconLink function to make favicons appear in your links to other websites. This brings more life to your external links and also tells your visitor that the link will open in a new window - most people now [...]]]></description>
			<content:encoded><![CDATA[<p>Put some style into your links.</p>
<p>By including this PHP script on your site, you can call the FaviconLink function to make favicons appear in your links to other websites. This brings more life to your external links and also tells your visitor that the link will open in a new window - most people now expect that this is what an icon on a link means.<br />
<span id="more-19"></span></p>
<div class="normal">
<p>text  text  text text  text  text<br />
Text text <a href="http://en.wikipedia.org" target="_blank">Wikipedia<img src="http://en.wikipedia.org/favicon.ico" style="width:0; height:0; left-margin:0;" onload="this.style.width='16px';this.style.height='16px';this.style.margin='0 0 0 4px';" align="middle" border="0" alt="" /></a> text  text  text<br />
text  text  text text  text  text<br />
text  text  text text  text  text </p>
<p>                      <a href="http://google.com" target="_blank"><img src="http://google.com/favicon.ico" style="width:0; height:0; left-margin:0;" onload="this.style.width='16px';this.style.height='16px';this.style.margin='0 3px 0 0';" align="middle" border="0" alt="" />Google</a><br />
                      <a href="http://yahoo.com" target="_blank"><img src="http://yahoo.com/favicon.ico" style="width:0; height:0; left-margin:0;" onload="this.style.width='16px';this.style.height='16px';this.style.margin='0 3px 0 0';" align="middle" border="0" alt="" />Yahoo</a><br />
                      <a href="http://en.wikipedia.org" target="_blank"><img src="http://en.wikipedia.org/favicon.ico" style="width:0; height:0; left-margin:0;" onload="this.style.width='16px';this.style.height='16px';this.style.margin='0 3px 0 0';" align="middle" border="0" alt="" />Wikipedia</a><br />
                      <a href="http://site-with-no-favicon.com" target="_blank"><img src="http://site-with-no-favicon.com/favicon.ico" style="width:0; height:0; left-margin:0;" onload="this.style.width='16px';this.style.height='16px';this.style.margin='0 3px 0 0';" align="middle" border="0" alt="" />"Site with no favicon.com"</a><br />
&nbsp;
</div>
<p>This script needs Javascript to be enabled but "degrades gracefully" if Javascript is not enabled on your visitor's browser or if  there is no <strong>"favicon.ico"</strong> file available on the remote website. In this case, no icon will appear, leaving the link as a standard link (no blank image or empty space).</p>
<p>Favicons can appear on the right (default) or on the left (list style display) of the link label.</p>
<pre class="php">&nbsp;
<span style="color: #A0A0A0; font-weight: bold;">&lt;?php</span>
&nbsp;
<a href="http://www.php.net/define"><span style="color: #808080;">define</span></a> <span style="color: #808080;">&#40;</span><span style="color: #FFC000;">'FL_ALIGN_RIGHT'</span>, <span style="color: #A0A0A0; font-weight: bold;">true</span> <span style="color: #808080;">&#41;</span>;
<a href="http://www.php.net/define"><span style="color: #808080;">define</span></a> <span style="color: #808080;">&#40;</span><span style="color: #FFC000;">'FL_ALIGN_LEFT'</span> , <span style="color: #A0A0A0; font-weight: bold;">false</span><span style="color: #808080;">&#41;</span>;
&nbsp;
<span style="color: #A0A0A0; font-weight: bold;">function</span> FaviconLink <span style="color: #808080;">&#40;</span><span style="color: #308ecf;">$iURL</span>, <span style="color: #308ecf;">$iLabel</span>=<span style="color: #A0A0A0; font-weight: bold;">null</span>, <span style="color: #308ecf;">$iAlign</span>=FL_ALIGN_RIGHT, <span style="color: #308ecf;">$iTarget</span>=<span style="color: #FFC000;">'_blank'</span><span style="color: #808080;">&#41;</span>
  <span style="color: #808080;">&#123;</span>
    <span style="color: #808080;">if</span> <span style="color: #808080;">&#40;</span><span style="color: #308ecf;">$iLabel</span>==<span style="color: #A0A0A0; font-weight: bold;">null</span><span style="color: #808080;">&#41;</span>
      <span style="color: #308ecf;">$iLabel</span> = <span style="color: #308ecf;">$iURL</span>;
&nbsp;
    <span style="color: #308ecf;">$iDomain</span> = <a href="http://www.php.net/str_replace"><span style="color: #808080;">str_replace</span></a><span style="color: #808080;">&#40;</span><a href="http://www.php.net/array"><span style="color: #808080;">array</span></a><span style="color: #808080;">&#40;</span><span style="color: #FFC000;">'http://'</span>,<span style="color: #FFC000;">'https://'</span><span style="color: #808080;">&#41;</span>, <span style="color: #FFC000;">''</span>, <a href="http://www.php.net/rawurldecode"><span style="color: #808080;">rawurldecode</span></a><span style="color: #808080;">&#40;</span><span style="color: #308ecf;">$iURL</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span>;
    <span style="color: #308ecf;">$aDomain</span> = <a href="http://www.php.net/explode"><span style="color: #808080;">explode</span></a><span style="color: #808080;">&#40;</span><span style="color: #FFC000;">'/'</span>, <a href="http://www.php.net/trim"><span style="color: #808080;">trim</span></a>  <span style="color: #808080;">&#40;</span><span style="color: #308ecf;">$iDomain</span>, <span style="color: #FFC000;">'/ '</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span>;
    <span style="color: #308ecf;">$iDomain</span> = <span style="color: #308ecf;">$aDomain</span><span style="color: #808080;">&#91;</span><span style="color: #FFC000;">0</span><span style="color: #808080;">&#93;</span>;
&nbsp;
    <span style="color: #808080;">if</span> <span style="color: #808080;">&#40;</span><span style="color: #308ecf;">$iAlign</span> == FL_ALIGN_RIGHT<span style="color: #808080;">&#41;</span>
        <a href="http://www.php.net/echo"><span style="color: #808080;">echo</span></a> &lt;&lt;&lt;HTML
          &lt;a href=<span style="color: #FFC000;">&quot;$iURL&quot;</span> target=<span style="color: #FFC000;">&quot;$iTarget&quot;</span>&gt;<span style="color: #308ecf;">$iLabel</span>&lt;img src=<span style="color: #FFC000;">&quot;http://$iDomain/favicon.ico&quot;</span> style=<span style="color: #FFC000;">&quot;width:0; height:0; left-margin:0;&quot;</span> onLoad=<span style="color: #FFC000;">&quot;this.style.width='16px';this.style.height='16px';this.style.margin='0 0 0 3px';&quot;</span> align=<span style="color: #FFC000;">&quot;middle&quot;</span> border=<span style="color: #FFC000;">&quot;0&quot;</span> alt=<span style="color: #FFC000;">&quot;&quot;</span> /&gt;&lt;/a&gt;
HTML;
      <span style="color: #808080;">else</span>
        <a href="http://www.php.net/echo"><span style="color: #808080;">echo</span></a> &lt;&lt;&lt;HTML
          &lt;a href=<span style="color: #FFC000;">&quot;$iURL&quot;</span> target=<span style="color: #FFC000;">&quot;$iTarget&quot;</span>&gt;&lt;img src=<span style="color: #FFC000;">&quot;http://$iDomain/favicon.ico&quot;</span> style=<span style="color: #FFC000;">&quot;width:0; height:0; left-margin:0;&quot;</span> onLoad=<span style="color: #FFC000;">&quot;this.style.width='16px';this.style.height='16px';this.style.margin='0 3px 0 0';&quot;</span> align=<span style="color: #FFC000;">&quot;middle&quot;</span> border=<span style="color: #FFC000;">&quot;0&quot;</span> alt=<span style="color: #FFC000;">&quot;&quot;</span> /&gt;<span style="color: #308ecf;">$iLabel</span>&lt;/a&gt;
HTML;
  <span style="color: #808080;">&#125;</span>
&nbsp;
<span style="color: #A0A0A0; font-weight: bold;">?&gt;</span>
&nbsp;</pre>
<p>Include this function in your code, then call it to get your "Faviconed Link":</p>
<pre class="php">&nbsp;
<span style="color: #A0A0A0; font-weight: bold;">&lt;?php</span>
&nbsp;
...
      FaviconLink <span style="color: #808080;">&#40;</span><span style="color: #FFC000;">'http://google.com'</span>, <span style="color: #FFC000;">'Google'</span><span style="color: #808080;">&#41;</span>;
...
<span style="color: #A0A0A0; font-weight: bold;">?&gt;</span>
&nbsp;</pre>
<p>You can download the function <a href="/FaviconLink.zip">here</a>.</p>
<p>This code is free to use and published under the GPL license.</p>
]]></content:encoded>
			<wfw:commentRss>http://mach13.com/improve-your-external-links-with-favicons/feed</wfw:commentRss>
		</item>
		<item>
		<title>How to protect and hide your mail address?</title>
		<link>http://mach13.com/how-to-protect-and-hide-your-mail-address</link>
		<comments>http://mach13.com/how-to-protect-and-hide-your-mail-address#comments</comments>
		<pubDate>Fri, 18 Nov 2005 08:46:23 +0000</pubDate>
		<dc:creator>Jean-Jacques Guegan</dc:creator>
		
		<category><![CDATA[Web Design]]></category>

		<guid isPermaLink="false">http://mach13.com/?p=21</guid>
		<description><![CDATA[Yet another Email Link Protector?
Yes, but I think this one is better:
all existing Javascript e-mail link protectors obfuscate your data with more or less complexity.  In my opinion, all these scripts have a major flaw:  they can all be recognized as e-mail link protectors by the best spam bots.

Look at any of these [...]]]></description>
			<content:encoded><![CDATA[<p>Yet another Email Link Protector?</p>
<p>Yes, but I think this one is better:<br />
all existing Javascript e-mail link protectors obfuscate your data with more or less complexity.  In my opinion, all these scripts have a major flaw:  they can all be recognized as e-mail link protectors by the best spam bots.<br />
<span id="more-21"></span><br />
Look at any of these scripts and imagine you are a spam bot designer - you'll see that code to find such javascript it is not very difficult to write.</p>
<p>They leave their signatures:</p>
<ul>
<li>Javascript file name</li>
<li>Programmer copyright</li>
<li>Variable name</li>
<li>"mailto:" , "Contact us" etc... strings</li>
</ul>
<p><br></p>
<p><b><u>The EmailProtect solution :</u></b></p>
<p>The EmailProtect code uses an algorithm strong enough to encrypt your address but with the smallest signature possible.  So it is difficult to detect.</p>
<p>EmailProtect Javascript uses the following code to decrypt the e-mail address :</p>
<pre class="javascript">&nbsp;
&lt;script type=<span style="color: #3366CC;">&quot;text/javascript&quot;</span>&gt;
&lt;!--
  link=<span style="color: #3366CC;">&quot;&quot;</span>
  coded = <span style="color: #3366CC;">&quot;Jbt1J0uodUQJb9J0aX1gTMNJbKl1XUJzu6gMUJ0fsNXJ0aJbffX1gTJ0uXUJ0uJ0ZJbtJ0P1Jbf&quot;</span>
  key = <span style="color: #3366CC;">&quot;2S1jo5J4CliU06ZwNvRztTgEuBOmyxLFMGqf3VcXp7YPrHDQbAsI8akhd%9WnKe&quot;</span>
  shift=coded.<span style="color: #006600;">length</span>
  keylength=key.<span style="color: #006600;">length</span>
&nbsp;
  k=<span style="color: #CC0000;">5</span>*keylength-shift;
&nbsp;
  <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #66cc66;">&#40;</span>i=<span style="color: #CC0000;">0</span>; i&lt;shift; i++<span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#123;</span>
    ltr = <span style="color: #66cc66;">&#40;</span>key.<span style="color: #006600;">indexOf</span><span style="color: #66cc66;">&#40;</span>coded.<span style="color: #006600;">charAt</span><span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>+k<span style="color: #66cc66;">&#41;</span> % keylength
    link += <span style="color: #66cc66;">&#40;</span>key.<span style="color: #006600;">charAt</span><span style="color: #66cc66;">&#40;</span>ltr<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
  document.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #66cc66;">&#40;</span>unescape<span style="color: #66cc66;">&#40;</span>link<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #009900; font-style: italic;">//--&gt;</span>
&lt;/script&gt;
&nbsp;</pre>
<p>The EmailProtect PHP function will generate the above javascript and will also :</p>
<ul>
<li>set all random variables (key)</li>
<li>set random variable names (and try not to interfere with javascript reserved words)</li>
<li>encode the e-mail address</li>
</ul>
<p><br></p>
<p>What bots will see in your HTML pages is the resulting javascript.  For example : </p>
<pre class="javascript">&nbsp;
&lt;script type=<span style="color: #3366CC;">&quot;text/javascript&quot;</span>&gt;
&lt;!--
&nbsp;
  o_=<span style="color: #3366CC;">&quot;&quot;</span>;
  ym=<span style="color: #3366CC;">&quot;owAroQcEhR5owBoQIgr821qowdargRoFcZ81RoQzDqgoQIowzgr82oQcgRowAoQtrowz&quot;</span>;
  q1=<span style="color: #3366CC;">&quot;WeIgX6R4L0KnFkcVatuDSr1OBHhJCsTElAZ3z2dywxQjbivp%N8PUof9MGq57mY&quot;</span>;
  j7=<span style="color: #CC0000;">46</span>;
  hn6=j7<span style="color: #CC0000;">+17</span>;
&nbsp;
  <span style="color: #000066; font-weight: bold;">for</span><span style="color: #66cc66;">&#40;</span>k4r=<span style="color: #CC0000;">0</span>; k4r&lt;<span style="color: #CC0000;">68</span>; k4r++<span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#123;</span>
    zq=<span style="color: #66cc66;">&#40;</span>q1.<span style="color: #006600;">indexOf</span><span style="color: #66cc66;">&#40;</span>ym.<span style="color: #006600;">charAt</span><span style="color: #66cc66;">&#40;</span>k4r<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #CC0000;">+247</span><span style="color: #66cc66;">&#41;</span>%hn6;
    o_+=q1.<span style="color: #006600;">charAt</span><span style="color: #66cc66;">&#40;</span>zq<span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
  document.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #66cc66;">&#40;</span>unescape<span style="color: #66cc66;">&#40;</span>o_<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #009900; font-style: italic;">//--&gt;</span>
&lt;/script&gt;
&nbsp;</pre>
<p><br><br />
Here is the code:</p>
<pre class="php">&nbsp;
<span style="color: #A0A0A0; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #A0A0A0; font-weight: bold;">function</span> EmailProtect <span style="color: #808080;">&#40;</span><span style="color: #308ecf;">$iAddress</span>, <span style="color: #308ecf;">$iText</span>, <span style="color: #308ecf;">$iCssClass</span>=<span style="color: #FFC000;">''</span><span style="color: #808080;">&#41;</span>
  <span style="color: #808080;">&#123;</span>
  <span style="color: #808080;">if</span> <span style="color: #808080;">&#40;</span><span style="color: #308ecf;">$iCssClass</span>!=<span style="color: #FFC000;">''</span><span style="color: #808080;">&#41;</span>
    <span style="color: #308ecf;">$iCssClass</span> = <span style="color: #FFC000;">&quot; class='$iCssClass'&quot;</span>;
&nbsp;
  <span style="color: #308ecf;">$iAddress</span> = <a href="http://www.php.net/rawurlencode"><span style="color: #808080;">rawurlencode</span></a><span style="color: #808080;">&#40;</span><span style="color: #FFC000;">&quot;&lt;a href='mailto:$iAddress'$iCssClass&gt;$iText&lt;/a&gt;&quot;</span><span style="color: #808080;">&#41;</span>;
  <span style="color: #308ecf;">$iAddress</span> = <a href="http://www.php.net/str_replace"><span style="color: #808080;">str_replace</span></a> <span style="color: #808080;">&#40;</span><span style="color: #FFC000;">'.'</span>,<span style="color: #FFC000;">'%2E'</span>,<span style="color: #308ecf;">$iAddress</span><span style="color: #808080;">&#41;</span>;
&nbsp;
  <span style="color: #308ecf;">$iKey</span>   = <a href="http://www.php.net/str_shuffle"><span style="color: #808080;">str_shuffle</span></a> <span style="color: #808080;">&#40;</span><span style="color: #FFC000;">'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%'</span><span style="color: #808080;">&#41;</span>;
  <span style="color: #308ecf;">$iCoded</span> = <span style="color: #FFC000;">''</span>;
&nbsp;
  <span style="color: #308ecf;">$iAddressLength</span> = <a href="http://www.php.net/strlen"><span style="color: #808080;">strlen</span></a><span style="color: #808080;">&#40;</span><span style="color: #308ecf;">$iAddress</span><span style="color: #808080;">&#41;</span>;
  <span style="color: #308ecf;">$iKeyLength</span>     = <a href="http://www.php.net/strlen"><span style="color: #808080;">strlen</span></a><span style="color: #808080;">&#40;</span><span style="color: #308ecf;">$iKey</span><span style="color: #808080;">&#41;</span>;
&nbsp;
  <span style="color: #808080;">for</span> <span style="color: #808080;">&#40;</span><span style="color: #308ecf;">$i</span>=<span style="color: #FFC000;">0</span>; <span style="color: #308ecf;">$i</span>&lt;<span style="color: #308ecf;">$iAddressLength</span>; <span style="color: #308ecf;">$i</span>++<span style="color: #808080;">&#41;</span>
    <span style="color: #808080;">&#123;</span>
    <span style="color: #308ecf;">$n</span> = <span style="color: #808080;">&#40;</span><a href="http://www.php.net/strpos"><span style="color: #808080;">strpos</span></a> <span style="color: #808080;">&#40;</span><span style="color: #308ecf;">$iKey</span>,<span style="color: #308ecf;">$iAddress</span><span style="color: #808080;">&#91;</span><span style="color: #308ecf;">$i</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#41;</span> + <span style="color: #308ecf;">$iAddressLength</span><span style="color: #808080;">&#41;</span> % <span style="color: #308ecf;">$iKeyLength</span>;
    <span style="color: #308ecf;">$iCoded</span> .= <span style="color: #308ecf;">$iKey</span><span style="color: #808080;">&#91;</span><span style="color: #308ecf;">$n</span><span style="color: #808080;">&#93;</span>;
    <span style="color: #808080;">&#125;</span>
&nbsp;
  <span style="color: #308ecf;">$iVarsFirst</span> = <a href="http://www.php.net/str_shuffle"><span style="color: #808080;">str_shuffle</span></a> <span style="color: #808080;">&#40;</span><span style="color: #FFC000;">'hjkmoqxyz'</span><span style="color: #808080;">&#41;</span>;                              <span style="color: #D8D8D8; font-style: italic;">// to prevent JavaScript from reserved word</span>
  <span style="color: #308ecf;">$iVars</span>      = <a href="http://www.php.net/str_shuffle"><span style="color: #808080;">str_shuffle</span></a> <span style="color: #808080;">&#40;</span><span style="color: #FFC000;">'abcdefghijklmnopqrstuvwxyz_0123456789'</span><span style="color: #808080;">&#41;</span>;
&nbsp;
  <span style="color: #808080;">for</span> <span style="color: #808080;">&#40;</span><span style="color: #308ecf;">$i</span>=<span style="color: #FFC000;">1</span>; <span style="color: #308ecf;">$i</span>&lt;=<span style="color: #FFC000;">7</span>; <span style="color: #308ecf;">$i</span>++<span style="color: #808080;">&#41;</span>
    <span style="color: #808080;">&#123;</span>
    <span style="color: #308ecf;">$aVar</span><span style="color: #808080;">&#91;</span><span style="color: #308ecf;">$i</span><span style="color: #808080;">&#93;</span> = <span style="color: #308ecf;">$iVarsFirst</span><span style="color: #808080;">&#91;</span><span style="color: #308ecf;">$i</span><span style="color: #808080;">&#93;</span>.<a href="http://www.php.net/substr"><span style="color: #808080;">substr</span></a><span style="color: #808080;">&#40;</span><span style="color: #308ecf;">$iVars</span>, <span style="color: #FFC000;">2</span>*<span style="color: #308ecf;">$i</span>, <a href="http://www.php.net/mt_rand"><span style="color: #808080;">mt_rand</span></a><span style="color: #808080;">&#40;</span><span style="color: #FFC000;">1</span>,<span style="color: #FFC000;">3</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span>;
    <span style="color: #808080;">&#125;</span>
&nbsp;
  <span style="color: #308ecf;">$k</span> = <a href="http://www.php.net/mt_rand"><span style="color: #808080;">mt_rand</span></a><span style="color: #808080;">&#40;</span><span style="color: #FFC000;">3</span>,<span style="color: #FFC000;">9</span><span style="color: #808080;">&#41;</span>*<span style="color: #308ecf;">$iKeyLength</span>-<span style="color: #308ecf;">$iAddressLength</span>;
&nbsp;
  <span style="color: #308ecf;">$k1</span> = <a href="http://www.php.net/mt_rand"><span style="color: #808080;">mt_rand</span></a><span style="color: #808080;">&#40;</span><span style="color: #FFC000;">2</span>,<span style="color: #308ecf;">$iKeyLength</span><span style="color: #FFC000;">-2</span><span style="color: #808080;">&#41;</span>;
  <span style="color: #308ecf;">$k2</span> = <span style="color: #308ecf;">$iKeyLength</span> - <span style="color: #308ecf;">$k1</span>;
&nbsp;
  <span style="color: #308ecf;">$iJavascript</span> = &lt;&lt;&lt;HTML
&nbsp;
<span style="color: #808080;">&#123;</span><span style="color: #308ecf;">$aVar</span><span style="color: #808080;">&#91;</span><span style="color: #FFC000;">5</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#125;</span>=<span style="color: #FFC000;">&quot;&quot;</span>;
<span style="color: #808080;">&#123;</span><span style="color: #308ecf;">$aVar</span><span style="color: #808080;">&#91;</span><span style="color: #FFC000;">1</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#125;</span>=<span style="color: #FFC000;">&quot;$iCoded&quot;</span>;
<span style="color: #808080;">&#123;</span><span style="color: #308ecf;">$aVar</span><span style="color: #808080;">&#91;</span><span style="color: #FFC000;">2</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#125;</span>=<span style="color: #FFC000;">&quot;$iKey&quot;</span>;
<span style="color: #808080;">&#123;</span><span style="color: #308ecf;">$aVar</span><span style="color: #808080;">&#91;</span><span style="color: #FFC000;">3</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#125;</span>=<span style="color: #308ecf;">$k1</span>;
<span style="color: #808080;">&#123;</span><span style="color: #308ecf;">$aVar</span><span style="color: #808080;">&#91;</span><span style="color: #FFC000;">4</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#125;</span>=<span style="color: #808080;">&#123;</span><span style="color: #308ecf;">$aVar</span><span style="color: #808080;">&#91;</span><span style="color: #FFC000;">3</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#125;</span>+<span style="color: #308ecf;">$k2</span>;
&nbsp;
<span style="color: #808080;">for</span><span style="color: #808080;">&#40;</span><span style="color: #808080;">&#123;</span><span style="color: #308ecf;">$aVar</span><span style="color: #808080;">&#91;</span><span style="color: #FFC000;">6</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#125;</span>=<span style="color: #FFC000;">0</span>; <span style="color: #808080;">&#123;</span><span style="color: #308ecf;">$aVar</span><span style="color: #808080;">&#91;</span><span style="color: #FFC000;">6</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#125;</span>&lt;<span style="color: #308ecf;">$iAddressLength</span>; <span style="color: #808080;">&#123;</span><span style="color: #308ecf;">$aVar</span><span style="color: #808080;">&#91;</span><span style="color: #FFC000;">6</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#125;</span>++<span style="color: #808080;">&#41;</span>
  <span style="color: #808080;">&#123;</span>
  <span style="color: #808080;">&#123;</span><span style="color: #308ecf;">$aVar</span><span style="color: #808080;">&#91;</span><span style="color: #FFC000;">7</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#125;</span>=<span style="color: #808080;">&#40;</span><span style="color: #808080;">&#123;</span><span style="color: #308ecf;">$aVar</span><span style="color: #808080;">&#91;</span><span style="color: #FFC000;">2</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#125;</span>.indexOf<span style="color: #808080;">&#40;</span><span style="color: #808080;">&#123;</span><span style="color: #308ecf;">$aVar</span><span style="color: #808080;">&#91;</span><span style="color: #FFC000;">1</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#125;</span>.charAt<span style="color: #808080;">&#40;</span><span style="color: #808080;">&#123;</span><span style="color: #308ecf;">$aVar</span><span style="color: #808080;">&#91;</span><span style="color: #FFC000;">6</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#125;</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span>+<span style="color: #308ecf;">$k</span><span style="color: #808080;">&#41;</span>%<span style="color: #808080;">&#123;</span><span style="color: #308ecf;">$aVar</span><span style="color: #808080;">&#91;</span><span style="color: #FFC000;">4</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#125;</span>;
  <span style="color: #808080;">&#123;</span><span style="color: #308ecf;">$aVar</span><span style="color: #808080;">&#91;</span><span style="color: #FFC000;">5</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#125;</span>+=<span style="color: #808080;">&#123;</span><span style="color: #308ecf;">$aVar</span><span style="color: #808080;">&#91;</span><span style="color: #FFC000;">2</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#125;</span>.charAt<span style="color: #808080;">&#40;</span><span style="color: #808080;">&#123;</span><span style="color: #308ecf;">$aVar</span><span style="color: #808080;">&#91;</span><span style="color: #FFC000;">7</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#125;</span><span style="color: #808080;">&#41;</span>;
  <span style="color: #808080;">&#125;</span>
&nbsp;
document.write<span style="color: #808080;">&#40;</span>unescape<span style="color: #808080;">&#40;</span><span style="color: #808080;">&#123;</span><span style="color: #308ecf;">$aVar</span><span style="color: #808080;">&#91;</span><span style="color: #FFC000;">5</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#125;</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span>;
&nbsp;
HTML;
&nbsp;
<span style="color: #D8D8D8; font-style: italic;">//  $iJavascript = str_replace(array(' ',&quot;\n&quot;,&quot;\r&quot;,&quot;\t&quot;),'',$iJavascript);</span>
&nbsp;
  <span style="color: #808080;">return</span> &lt;&lt;&lt;HTML
&lt;script type=<span style="color: #FFC000;">&quot;text/javascript&quot;</span>&gt;
    &lt;!--
    <span style="color: #308ecf;">$iJavascript</span>
    <span style="color: #D8D8D8; font-style: italic;">//--&gt;</span>
<span style="color: #A0A0A0; font-weight: bold;">&lt;/script&gt;</span>
HTML;
&nbsp;
  <span style="color: #808080;">&#125;</span>
<span style="color: #A0A0A0; font-weight: bold;">?&gt;</span>
&nbsp;</pre>
<p><br></p>
<p>Just include the EmailProtect function in your scripts and call it each time you need to protect an e-mail address :</p>
<pre class="php">&nbsp;
&nbsp;
... HTML ... <span style="color: #A0A0A0; font-weight: bold;">&lt;?</span>=EmailProtect <span style="color: #808080;">&#40;</span><span style="color: #FFC000;">'me@mail.com'</span>, <span style="color: #FFC000;">'Contact me'</span><span style="color: #808080;">&#41;</span>; <span style="color: #A0A0A0; font-weight: bold;">?&gt;</span> ... HTML ...
...
&nbsp;</pre>
<p>The code is available <a href="EmailProtect.zip">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://mach13.com/how-to-protect-and-hide-your-mail-address/feed</wfw:commentRss>
		</item>
		<item>
		<title>How to get a variable name as a string in PHP</title>
		<link>http://mach13.com/how-to-get-a-variable-name-as-a-string-in-php</link>
		<comments>http://mach13.com/how-to-get-a-variable-name-as-a-string-in-php#comments</comments>
		<pubDate>Fri, 18 Nov 2005 08:02:34 +0000</pubDate>
		<dc:creator>Jean-Jacques Guegan</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://mach13.com/?p=7</guid>
		<description><![CDATA[On rare occasions, you may need to retrieve a variable name as a string. 
This handy little function retreives the name of the variable:
&#160;
&#60;?php
      $my_var = 1;
      echo var_name &#40;$my_var&#41;;
?&#62;
&#160;
 will give 'my_var'. 

I started trying to find a solution to this problem, because I [...]]]></description>
			<content:encoded><![CDATA[<p>On rare occasions, you may need to retrieve a <strong>variable name as a string</strong>. </p>
<p>This handy little function retreives the name of the variable:</p>
<pre class="php">&nbsp;
<span style="color: #A0A0A0; font-weight: bold;">&lt;?php</span>
      <span style="color: #308ecf;">$my_var</span> = <span style="color: #FFC000;">1</span>;
      <a href="http://www.php.net/echo"><span style="color: #808080;">echo</span></a> var_name <span style="color: #808080;">&#40;</span><span style="color: #308ecf;">$my_var</span><span style="color: #808080;">&#41;</span>;
<span style="color: #A0A0A0; font-weight: bold;">?&gt;</span>
&nbsp;</pre>
<p> will give 'my_var'. </p>
<p><span id="more-7"></span></p>
<p>I started trying to find a solution to this problem, because I needed such a function and because questions about it appeared on several mailing lists and forums:<br />
<a href="http://marc.theaimsgroup.com/?l=php-general&m=112173649723474&w=2" target="_blank">[PHP] Is there a way to get a variable name as a string?</a></p>
<p>most people said it was not possible...<br />
<a href="http://marc.theaimsgroup.com/?l=php-general&m=112174126218786&w=2" target="_blank">Re: [PHP] Is there a way to get a variable name as a string?<br />
From:       Rasmus Lerdorf</a></p>
<p>In PHP it is possible to use a variable if you have its name as a string :</p>
<pre class="php">&nbsp;
<span style="color: #A0A0A0; font-weight: bold;">&lt;?php</span>
&nbsp;
    <span style="color: #308ecf;">$iVarName</span> = <span style="color: #FFC000;">'MaxSize'</span>;
    <span style="color: #308ecf;">$$iVarName</span> = <span style="color: #FFC000;">10</span>;
    <a href="http://www.php.net/echo"><span style="color: #808080;">echo</span></a> <span style="color: #308ecf;">$MaxSize</span>;
&nbsp;
<span style="color: #A0A0A0; font-weight: bold;">?&gt;</span>
&nbsp;</pre>
<p>But <strong>PHP</strong> does not natively include a way to get the name of a given variable.</p>
<p>This might be useful in situations where you design a function with a parameter passed by reference and you need to know which variable was sent as a parameter for this function.</p>
<p>&nbsp;</p>
<p><u><strong>The solution :</strong></u></p>
<p>The following function retreives the variable name from a given variable:</p>
<pre class="php">&nbsp;
<span style="color: #A0A0A0; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #A0A0A0; font-weight: bold;">function</span> var_name <span style="color: #808080;">&#40;</span>&amp;<span style="color: #308ecf;">$iVar</span>, &amp;<span style="color: #308ecf;">$aDefinedVars</span><span style="color: #808080;">&#41;</span>
    <span style="color: #808080;">&#123;</span>
    <span style="color: #808080;">foreach</span> <span style="color: #808080;">&#40;</span><span style="color: #308ecf;">$aDefinedVars</span> <span style="color: #808080;">as</span> <span style="color: #308ecf;">$k</span>=&gt;<span style="color: #308ecf;">$v</span><span style="color: #808080;">&#41;</span>
        <span style="color: #308ecf;">$aDefinedVars_0</span><span style="color: #808080;">&#91;</span><span style="color: #308ecf;">$k</span><span style="color: #808080;">&#93;</span> = <span style="color: #308ecf;">$v</span>;
&nbsp;
    <span style="color: #308ecf;">$iVarSave</span> = <span style="color: #308ecf;">$iVar</span>;
    <span style="color: #308ecf;">$iVar</span>     =!<span style="color: #308ecf;">$iVar</span>;
&nbsp;
    <span style="color: #308ecf;">$aDiffKeys</span> = <a href="http://www.php.net/array_keys"><span style="color: #808080;">array_keys</span></a> <span style="color: #808080;">&#40;</span><a href="http://www.php.net/array_diff_assoc"><span style="color: #808080;">array_diff_assoc</span></a> <span style="color: #808080;">&#40;</span><span style="color: #308ecf;">$aDefinedVars_0</span>, <span style="color: #308ecf;">$aDefinedVars</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span>;
    <span style="color: #308ecf;">$iVar</span>      = <span style="color: #308ecf;">$iVarSave</span>;
&nbsp;
    <span style="color: #808080;">return</span> <span style="color: #308ecf;">$aDiffKeys</span><span style="color: #808080;">&#91;</span><span style="color: #FFC000;">0</span><span style="color: #808080;">&#93;</span>;
    <span style="color: #808080;">&#125;</span>
&nbsp;
<span style="color: #A0A0A0; font-weight: bold;">?&gt;</span>
&nbsp;</pre>
<p>This function has to be called with a second parameter always set to the result of the function <strong>"get_defined_vars()"</strong>:</p>
<pre class="php">&nbsp;
<span style="color: #A0A0A0; font-weight: bold;">&lt;?php</span>	
&nbsp;
var_name<span style="color: #808080;">&#40;</span><span style="color: #308ecf;">$iVar</span>, <a href="http://www.php.net/get_defined_vars"><span style="color: #808080;">get_defined_vars</span></a><span style="color: #808080;">&#40;</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span>;
&nbsp;
<span style="color: #A0A0A0; font-weight: bold;">?&gt;</span>
&nbsp;</pre>
<p>&nbsp;</p>
<p><u><strong>How does it work ?</strong></u></p>
<p><strong>var_name</strong> compares the result of the function <strong>"get_defined_vars()"</strong> before and after modification of the variable whose name we want to find.</p>
<p>The initial set of defined variables passed as a parameter to <strong>var_name</strong> is first stored in <strong>"$aDefinedVars_0"</strong> and compared later.</p>
<p>Before modifying the value of the variable, its value is saved in <strong>$iVarSave</strong>.</p>
<p><strong>$iVar</strong> is then changed to something different :<br />
$iVar=!$iVar;</p>
<p>$aDefinedVars keeps track of this modification and can be compare to $aDefinedVars_0 (its initial value). The difference is the variable we modified and we can get its name as a string in the key value of the array record.</p>
<p>The value of the variable is restored to its initial value kept in <strong>$iVarSave</strong> and the name of the variable is returned.</p>
<p>&nbsp;</p>
<p><u><strong>Example :</strong></u></p>
<p>The following PHP code shows the function var_name in action:</p>
<pre class="php">&nbsp;
<span style="color: #A0A0A0; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #308ecf;">$v_1</span> = <span style="color: #FFC000;">1</span>;                               <a href="http://www.php.net/echo"><span style="color: #808080;">echo</span></a> <span style="color: #FFC000;">'var $&lt;b&gt;'</span>,var_name <span style="color: #808080;">&#40;</span><span style="color: #308ecf;">$v_1</span>, <a href="http://www.php.net/get_defined_vars"><span style="color: #808080;">get_defined_vars</span></a><span style="color: #808080;">&#40;</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span>,<span style="color: #FFC000;">'&lt;/b&gt; = '</span>,<a href="http://www.php.net/var_dump"><span style="color: #808080;">var_dump</span></a><span style="color: #808080;">&#40;</span><span style="color: #308ecf;">$v_1</span><span style="color: #808080;">&#41;</span>,<span style="color: #FFC000;">'&lt;br&gt;'</span>;
<span style="color: #308ecf;">$v_2</span> = <span style="color: #FFC000;">4</span>;                               <a href="http://www.php.net/echo"><span style="color: #808080;">echo</span></a> <span style="color: #FFC000;">'var $&lt;b&gt;'</span>,var_name <span style="color: #808080;">&#40;</span><span style="color: #308ecf;">$v_2</span>, <a href="http://www.php.net/get_defined_vars"><span style="color: #808080;">get_defined_vars</span></a><span style="color: #808080;">&#40;</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span>,<span style="color: #FFC000;">'&lt;/b&gt; = '</span>,<a href="http://www.php.net/var_dump"><span style="color: #808080;">var_dump</span></a><span style="color: #808080;">&#40;</span><span style="color: #308ecf;">$v_2</span><span style="color: #808080;">&#41;</span>,<span style="color: #FFC000;">'&lt;br&gt;'</span>;
<span style="color: #308ecf;">$v_3</span> = <span style="color: #FFC000;">'qwerty'</span>;                        <a href="http://www.php.net/echo"><span style="color: #808080;">echo</span></a> <span style="color: #FFC000;">'var $&lt;b&gt;'</span>,var_name <span style="color: #808080;">&#40;</span><span style="color: #308ecf;">$v_3</span>, <a href="http://www.php.net/get_defined_vars"><span style="color: #808080;">get_defined_vars</span></a><span style="color: #808080;">&#40;</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span>,<span style="color: #FFC000;">'&lt;/b&gt; = '</span>,<a href="http://www.php.net/var_dump"><span style="color: #808080;">var_dump</span></a><span style="color: #808080;">&#40;</span><span style="color: #308ecf;">$v_3</span><span style="color: #808080;">&#41;</span>,<span style="color: #FFC000;">'&lt;br&gt;'</span>;
<span style="color: #308ecf;">$v_4</span> = <a href="http://www.php.net/array"><span style="color: #808080;">array</span></a><span style="color: #808080;">&#40;</span><span style="color: #FFC000;">'aa'</span>=&gt;<span style="color: #FFC000;">'11'</span>,<span style="color: #FFC000;">'bb'</span>=&gt;<span style="color: #FFC000;">'22'</span>,<span style="color: #FFC000;">3</span><span style="color: #808080;">&#41;</span>;  <a href="http://www.php.net/echo"><span style="color: #808080;">echo</span></a> <span style="color: #FFC000;">'var $&lt;b&gt;'</span>,var_name <span style="color: #808080;">&#40;</span><span style="color: #308ecf;">$v_4</span>, <a href="http://www.php.net/get_defined_vars"><span style="color: #808080;">get_defined_vars</span></a><span style="color: #808080;">&#40;</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span>,<span style="color: #FFC000;">'&lt;/b&gt; = '</span>,<a href="http://www.php.net/var_dump"><span style="color: #808080;">var_dump</span></a><span style="color: #808080;">&#40;</span><span style="color: #308ecf;">$v_4</span><span style="color: #808080;">&#41;</span>,<span style="color: #FFC000;">'&lt;br&gt;'</span>;
<span style="color: #308ecf;">$v_5</span> = &amp;<span style="color: #308ecf;">$v_2</span>;                           <a href="http://www.php.net/echo"><span style="color: #808080;">echo</span></a> <span style="color: #FFC000;">'var $&lt;b&gt;'</span>,var_name <span style="color: #808080;">&#40;</span><span style="color: #308ecf;">$v_5</span>, <a href="http://www.php.net/get_defined_vars"><span style="color: #808080;">get_defined_vars</span></a><span style="color: #808080;">&#40;</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span>,<span style="color: #FFC000;">'&lt;/b&gt; = '</span>,<a href="http://www.php.net/var_dump"><span style="color: #808080;">var_dump</span></a><span style="color: #808080;">&#40;</span><span style="color: #308ecf;">$v_5</span><span style="color: #808080;">&#41;</span>,<span style="color: #FFC000;">'&lt;br&gt;'</span>;
                                        <a href="http://www.php.net/echo"><span style="color: #808080;">echo</span></a> <span style="color: #FFC000;">'var $&lt;b&gt;'</span>,<a href="http://www.php.net/implode"><span style="color: #808080;">implode</span></a> <span style="color: #808080;">&#40;</span><span style="color: #FFC000;">'&lt;/b&gt; / $&lt;b&gt;'</span>,var_name <span style="color: #808080;">&#40;</span><span style="color: #308ecf;">$v_5</span>, <a href="http://www.php.net/get_defined_vars"><span style="color: #808080;">get_defined_vars</span></a><span style="color: #808080;">&#40;</span><span style="color: #808080;">&#41;</span>,<span style="color: #A0A0A0; font-weight: bold;">true</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span>,<span style="color: #FFC000;">'&lt;/b&gt; = '</span>,<a href="http://www.php.net/var_dump"><span style="color: #808080;">var_dump</span></a><span style="color: #808080;">&#40;</span><span style="color: #308ecf;">$v_5</span><span style="color: #808080;">&#41;</span>,<span style="color: #FFC000;">'&lt;br&gt;'</span>;
&nbsp;
<span style="color: #A0A0A0; font-weight: bold;">function</span> test<span style="color: #808080;">&#40;</span><span style="color: #808080;">&#41;</span>
    <span style="color: #808080;">&#123;</span>
    <span style="color: #308ecf;">$v_1</span> = <span style="color: #FFC000;">'qwerty'</span>;                    <a href="http://www.php.net/echo"><span style="color: #808080;">echo</span></a> <span style="color: #FFC000;">'var $&lt;b&gt;'</span>,var_name <span style="color: #808080;">&#40;</span><span style="color: #308ecf;">$v_1</span>, <a href="http://www.php.net/get_defined_vars"><span style="color: #808080;">get_defined_vars</span></a><span style="color: #808080;">&#40;</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span>,<span style="color: #FFC000;">'&lt;/b&gt; = '</span>,<a href="http://www.php.net/var_dump"><span style="color: #808080;">var_dump</span></a><span style="color: #808080;">&#40;</span><span style="color: #308ecf;">$v_1</span><span style="color: #808080;">&#41;</span>,<span style="color: #FFC000;">'&lt;br&gt;
&lt;hr&gt;'</span>;
    <a href="http://www.php.net/global"><span style="color: #808080;">global</span></a> <span style="color: #308ecf;">$v_5</span>;                 <a href="http://www.php.net/echo"><span style="color: #808080;">echo</span></a> <span style="color: #FFC000;">'var $&lt;b&gt;'</span>,var_name <span style="color: #808080;">&#40;</span><span style="color: #308ecf;">$v_5</span>, <a href="http://www.php.net/get_defined_vars"><span style="color: #808080;">get_defined_vars</span></a><span style="color: #808080;">&#40;</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span>,<span style="color: #FFC000;">'&lt;/b&gt; = '</span>,<a href="http://www.php.net/var_dump"><span style="color: #808080;">var_dump</span></a><span style="color: #808080;">&#40;</span><span style="color: #308ecf;">$v_5</span><span style="color: #808080;">&#41;</span>,<span style="color: #FFC000;">'&lt;br&gt;
&lt;hr&gt;'</span>;
    <span style="color: #808080;">&#125;</span>
&nbsp;
test<span style="color: #808080;">&#40;</span><span style="color: #808080;">&#41;</span>;
&nbsp;
<span style="color: #A0A0A0; font-weight: bold;">?&gt;</span>
&nbsp;</pre>
<p><strong>var_name </strong>can retreive the name of the variable in every case.</p>
<p>&nbsp;</p>
<p><u><strong>Application :</strong></u></p>
<p>The most direct application of this function is, of course, a <strong>"dump" </strong>function.<br />
Just call this "dump" function with the variable you want to monitor - do not forget to add the "get_defined_vars()" parameter...</p>
<pre class="php">&nbsp;
<span style="color: #A0A0A0; font-weight: bold;">&lt;?php</span>	
&nbsp;
<span style="color: #A0A0A0; font-weight: bold;">function</span> dump<span style="color: #808080;">&#40;</span>&amp;<span style="color: #308ecf;">$v</span>, &amp;<span style="color: #308ecf;">$aDefinedVars</span><span style="color: #808080;">&#41;</span>
    <span style="color: #808080;">&#123;</span>
    <a href="http://www.php.net/echo"><span style="color: #808080;">echo</span></a> <span style="color: #FFC000;">'
&lt;pre&gt;$&lt;b&gt;'</span>,<a href="http://www.php.net/implode"><span style="color: #808080;">implode</span></a> <span style="color: #808080;">&#40;</span><span style="color: #FFC000;">'&lt;/b&gt; / $&lt;b&gt;'</span>,var_name <span style="color: #808080;">&#40;</span><span style="color: #308ecf;">$v</span>, <span style="color: #308ecf;">$aDefinedVars</span>, <span style="color: #A0A0A0; font-weight: bold;">true</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span>,<span style="color: #FFC000;">'&lt;/b&gt; = '</span>,<a href="http://www.php.net/print_r"><span style="color: #808080;">print_r</span></a><span style="color: #808080;">&#40;</span><span style="color: #308ecf;">$v</span>, <span style="color: #A0A0A0; font-weight: bold;">true</span><span style="color: #808080;">&#41;</span>,<span style="color: #FFC000;">'&lt;/ pre&gt;&lt;br&gt;
&lt;hr&gt;'</span>;
    <span style="color: #808080;">&#125;</span>
&nbsp;
dump<span style="color: #808080;">&#40;</span><span style="color: #308ecf;">$v_4</span>, <a href="http://www.php.net/get_defined_vars"><span style="color: #808080;">get_defined_vars</span></a><span style="color: #808080;">&#40;</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span>;
&nbsp;
<span style="color: #A0A0A0; font-weight: bold;">?&gt;</span>
&nbsp;</pre>
<p>&nbsp;</p>
<p><u><strong>Going further :</strong></u></p>
<p>The function <strong>var_name</strong> can be enhanced by adding the parameter <strong>$bShowAllRef </strong>to show, if set to true, all the references relating to the variable passed as a parameter:</p>
<pre class="php">&nbsp;
<span style="color: #A0A0A0; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #A0A0A0; font-weight: bold;">function</span> var_name <span style="color: #808080;">&#40;</span>&amp;<span style="color: #308ecf;">$iVar</span>, &amp;<span style="color: #308ecf;">$aDefinedVars</span>, <span style="color: #308ecf;">$bShowAllRef</span>=<span style="color: #A0A0A0; font-weight: bold;">false</span> <span style="color: #808080;">&#41;</span>
    <span style="color: #808080;">&#123;</span>
    <span style="color: #808080;">foreach</span> <span style="color: #808080;">&#40;</span><span style="color: #308ecf;">$aDefinedVars</span> <span style="color: #808080;">as</span> <span style="color: #308ecf;">$k</span>=&gt;<span style="color: #308ecf;">$v</span><span style="color: #808080;">&#41;</span>
        <span style="color: #308ecf;">$aDefinedVars_0</span><span style="color: #808080;">&#91;</span><span style="color: #308ecf;">$k</span><span style="color: #808080;">&#93;</span> = <span style="color: #308ecf;">$v</span>;
&nbsp;
    <span style="color: #308ecf;">$iVarSave</span> = <span style="color: #308ecf;">$iVar</span>;
    <span style="color: #308ecf;">$iVar</span>     =!<span style="color: #308ecf;">$iVar</span>;
&nbsp;
    <span style="color: #308ecf;">$aDiffKeys</span> = <a href="http://www.php.net/array_keys"><span style="color: #808080;">array_keys</span></a> <span style="color: #808080;">&#40;</span><a href="http://www.php.net/array_diff_assoc"><span style="color: #808080;">array_diff_assoc</span></a> <span style="color: #808080;">&#40;</span><span style="color: #308ecf;">$aDefinedVars_0</span>, <span style="color: #308ecf;">$aDefinedVars</span><span style="color: #808080;">&#41;</span><span style="color: #808080;">&#41;</span>;
    <span style="color: #308ecf;">$iVar</span>      = <span style="color: #308ecf;">$iVarSave</span>;
&nbsp;
    <span style="color: #808080;">return</span> <span style="color: #808080;">&#40;</span><span style="color: #308ecf;">$bShowAllRef</span>? <span style="color: #308ecf;">$aDiffKeys</span>: <span style="color: #308ecf;">$aDiffKeys</span><span style="color: #808080;">&#91;</span><span style="color: #FFC000;">0</span><span style="color: #808080;">&#93;</span><span style="color: #808080;">&#41;</span>;
    <span style="color: #808080;">&#125;</span>
&nbsp;
<span style="color: #A0A0A0; font-weight: bold;">?&gt;</span>
&nbsp;</pre>
<p>That's it !  You can download the function <a href="/var_name.zip">here</a>.</p>
<p>This code is free to use and published under the GPL license.</p>
]]></content:encoded>
			<wfw:commentRss>http://mach13.com/how-to-get-a-variable-name-as-a-string-in-php/feed</wfw:commentRss>
		</item>
		<item>
		<title>Why Mach13 ?</title>
		<link>http://mach13.com/why-mach13</link>
		<comments>http://mach13.com/why-mach13#comments</comments>
		<pubDate>Wed, 16 Nov 2005 08:48:46 +0000</pubDate>
		<dc:creator>Jean-Jacques Guegan</dc:creator>
		
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://mach13.com/?p=23</guid>
		<description><![CDATA[I was trying to find a domain name for my IT related blog, with a strong consonnance of HighTech,  power, speed and lightweight.
Something a bit scarry would fit me too...

The interesting fact about Mach13 is that it combines the step speed of 10,000 miles per hour with the frightening 13 number...
Some people already reached [...]]]></description>
			<content:encoded><![CDATA[<p>I was trying to find a domain name for my IT related blog, with a strong consonnance of HighTech,  power, speed and lightweight.</p>
<p>Something a bit scarry would fit me too...<br />
<span id="more-23"></span><br />
The interesting fact about <strong>Mach13 </strong>is that it combines the step speed of 10,000 miles per hour with the frightening 13 number...</p>
<p><img src="http://mach13.com/img/x33-s.jpg" alt="x-33" align="right" hspace="10" />Some people already reached that speed (Space Shuttle Team for example)  and some plane projects were designed with this maximum speed as a goal (x-33).</p>
<p>I hope you are not triskaidekaphobic so you can fully enjoy <strong>Mach13.com</strong>.</p>
]]></content:encoded>
			<wfw:commentRss>http://mach13.com/why-mach13/feed</wfw:commentRss>
		</item>
	</channel>
</rss>

<!-- e-pla.net::website monitoring -->



