<?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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>James Border &#187; PHP</title>
	<atom:link href="http://jamesborder.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://jamesborder.com</link>
	<description>Interactive/Mobile/iOS Developer</description>
	<lastBuildDate>Fri, 03 Feb 2012 03:17:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>var_dump() as a string</title>
		<link>http://jamesborder.com/2011/11/var_dump-as-a-string/</link>
		<comments>http://jamesborder.com/2011/11/var_dump-as-a-string/#comments</comments>
		<pubDate>Sun, 20 Nov 2011 06:56:16 +0000</pubDate>
		<dc:creator>me</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://jamesborder.com/?p=940</guid>
		<description><![CDATA[DO NOT use on live/production site. ob_start(); var_dump($something_anything); $yourResultingString = ob_get_clean();]]></description>
			<content:encoded><![CDATA[<p>DO NOT use on live/production site.</p>
<p><code></p>
<p>ob_start();<br />
var_dump($something_anything);<br />
$yourResultingString = ob_get_clean();</p>
<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://jamesborder.com/2011/11/var_dump-as-a-string/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>php Get Protocol</title>
		<link>http://jamesborder.com/2011/07/php-get-protocol/</link>
		<comments>http://jamesborder.com/2011/07/php-get-protocol/#comments</comments>
		<pubDate>Tue, 12 Jul 2011 08:01:17 +0000</pubDate>
		<dc:creator>me</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://jamesborder.com/?p=853</guid>
		<description><![CDATA[taken directly from: http://readytousesolutions.com/phpblog/php-tutorial-get-protocol/]]></description>
			<content:encoded><![CDATA[<p><?php<br />
$protocol = strtolower(substr($_SERVER["SERVER_PROTOCOL"],0,5))=='https'?'https':'http';<br />
print "The protocol is $protocol";<br />
?></p>
<p>taken directly from:</p>
<p>http://readytousesolutions.com/phpblog/php-tutorial-get-protocol/</p>
]]></content:encoded>
			<wfw:commentRss>http://jamesborder.com/2011/07/php-get-protocol/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google analytics &#8211; track click to a file</title>
		<link>http://jamesborder.com/2010/05/google-analytics-track-click-to-a-file/</link>
		<comments>http://jamesborder.com/2010/05/google-analytics-track-click-to-a-file/#comments</comments>
		<pubDate>Thu, 20 May 2010 22:57:12 +0000</pubDate>
		<dc:creator>me</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://jamesborder.com/?p=539</guid>
		<description><![CDATA[&#60;html> &#60;head> &#60;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> &#60;title>File to track &#60;script type="text/javascript"> &#60;!-- function MM_goToURL() { //v3.0 var i, args=MM_goToURL.arguments; document.MM_returnValue = false; for (i=0; i &#60;/script> &#60;/head> &#60;body onLoad="MM_goToURL('parent','pdfs/file_name_here.pdf');return document.MM_returnValue"> &#60;script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); &#60;/script> &#60;script type="text/javascript"> try{ var <a href='http://jamesborder.com/2010/05/google-analytics-track-click-to-a-file/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p><code>&lt;html><br />
&lt;head><br />
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><br />
&lt;title>File to track</title></p>
<p>&lt;script type="text/javascript"><br />
&lt;!--<br />
function MM_goToURL() { //v3.0<br />
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;<br />
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");<br />
}<br />
//--><br />
&lt;/script><br />
&lt;/head></p>
<p>&lt;body onLoad="MM_goToURL('parent','pdfs/file_name_here.pdf');return document.MM_returnValue"></p>
<p>&lt;script type="text/javascript"><br />
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");<br />
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));<br />
&lt;/script><br />
&lt;script type="text/javascript"><br />
try{<br />
var pageTracker = _gat._getTracker("UA-1234567-1");<br />
	pageTracker._trackPageview();<br />
} catch(err) {}<br />
&lt;/script><br />
&lt;/body></code></p>
]]></content:encoded>
			<wfw:commentRss>http://jamesborder.com/2010/05/google-analytics-track-click-to-a-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>php &#8211; The execution operator</title>
		<link>http://jamesborder.com/2009/12/php-the-execution-operator/</link>
		<comments>http://jamesborder.com/2009/12/php-the-execution-operator/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 13:24:21 +0000</pubDate>
		<dc:creator>me</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://jamesborder.com/?p=308</guid>
		<description><![CDATA[**** note the back ticks not single quote ****** executes the contents of the ticks as if you are at the terminal but as apache or whoever your web server is. this code basically echo `whoami`; // well who is this script running as echo `pwd`; // think whereami echo `mkdir test`; // make a <a href='http://jamesborder.com/2009/12/php-the-execution-operator/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>**** note the back ticks not single quote ******</p>
<p>executes the contents of the ticks as if you are at the terminal but as apache or whoever your web server is. this code basically<br />
<code><br />
echo `whoami`;	// well who is this script running as</p>
<p>echo `pwd`;	// think whereami<br />
echo `mkdir test`;	// make a directory<br />
echo `mkdir test/anothertest`;	// make a directory in the directory created<br />
echo nl2br(`ls`);	// list what is in this directory</p>
<p>`touch log.txt`;	// make a text file named log.txt</p>
<p>$date = date("F j, Y, g:i a");<br />
`echo $date > log.txt`;		// writes the $date to log.txt<br />
`echo foo >> log.txt`;		// writes foo to log.txt<br />
echo nl2br(`cat log.txt`);	// echoes what is in log.txt</p>
<p>echo nl2br(`tail /opt/local/apache2/logs/error_log`);	// echoes what is in the error_log</p>
<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://jamesborder.com/2009/12/php-the-execution-operator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP alpha numeric only strings</title>
		<link>http://jamesborder.com/2009/10/php-alpha-numeric-only-strings/</link>
		<comments>http://jamesborder.com/2009/10/php-alpha-numeric-only-strings/#comments</comments>
		<pubDate>Sat, 17 Oct 2009 05:25:34 +0000</pubDate>
		<dc:creator>me</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://jamesborder.com/?p=290</guid>
		<description><![CDATA[$str = &#8220;@ % * alpha numeric 0 &#8211; 9 only _ &#8211; +@_#()()++&#8221;; $str = preg_replace(&#8216;/[^A-Za-z0-9]/&#8217;, &#8221;, $str); echo $str; returns alphanumeric09only]]></description>
			<content:encoded><![CDATA[<p>$str = &#8220;@ % * alpha numeric 0 &#8211; 9 only _ &#8211; +@_#()()++&#8221;;<br />
$str = preg_replace(&#8216;/[^A-Za-z0-9]/&#8217;, &#8221;, $str);</p>
<p>echo $str;<br />
returns alphanumeric09only</p>
]]></content:encoded>
			<wfw:commentRss>http://jamesborder.com/2009/10/php-alpha-numeric-only-strings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Short tags</title>
		<link>http://jamesborder.com/2009/10/php-short-tags/</link>
		<comments>http://jamesborder.com/2009/10/php-short-tags/#comments</comments>
		<pubDate>Sat, 10 Oct 2009 04:32:52 +0000</pubDate>
		<dc:creator>me</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://jamesborder.com/?p=360</guid>
		<description><![CDATA[enable by setting the flag in .htaccess php_flag short_open_tag on Open php.ini ( /etc/php.ini or /usr/local/etc/php.ini), enter: # vi php.ini Set short_open_tag to On: short_open_tag = On Save and close the file. Restart webserver: # service httpd restart or # /etc/init.d/httpd graceful]]></description>
			<content:encoded><![CDATA[<p>enable by setting the flag in .htaccess</p>
<p>php_flag short_open_tag on</p>
<p>Open php.ini ( /etc/php.ini or /usr/local/etc/php.ini), enter:<br />
# vi php.ini</p>
<p>Set short_open_tag to On:<br />
short_open_tag = On</p>
<p>Save and close the file. Restart webserver:<br />
# service httpd restart<br />
or<br />
# /etc/init.d/httpd graceful</p>
]]></content:encoded>
			<wfw:commentRss>http://jamesborder.com/2009/10/php-short-tags/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wolf CMS &#8211; Clean uploaded file names</title>
		<link>http://jamesborder.com/2009/09/wolf-cms-clean-uploaded-file-names/</link>
		<comments>http://jamesborder.com/2009/09/wolf-cms-clean-uploaded-file-names/#comments</comments>
		<pubDate>Fri, 25 Sep 2009 20:09:02 +0000</pubDate>
		<dc:creator>me</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://jamesborder.com/?p=447</guid>
		<description><![CDATA[To replace spaces with underscores and then remove everything that isn&#8217;t alpha-numeric open up wolf/plugins/file_manager.FileManagerController.php and replace the existing upload function (approx line 259) with this. public function upload() { $data = $_POST['upload']; $path = str_replace('..', '', $data['path']); $overwrite = isset($data['overwrite']) ? true: false; if (isset($_FILES)) { // $file = upload_file($_FILES['upload_file']['name'], FILES_DIR.'/'.$path.'/', $_FILES['upload_file']['tmp_name'], $overwrite); $clean_file_name <a href='http://jamesborder.com/2009/09/wolf-cms-clean-uploaded-file-names/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>To replace spaces with underscores and then remove everything that isn&#8217;t alpha-numeric open up </p>
<p>wolf/plugins/file_manager.FileManagerController.php</p>
<p>and replace the existing upload function (approx line 259) with this.<br />
<code><br />
    public function upload() {<br />
        $data = $_POST['upload'];<br />
        $path = str_replace('..', '', $data['path']);<br />
        $overwrite = isset($data['overwrite']) ? true: false;</p>
<p>        if (isset($_FILES)) {</p>
<p>			//	$file = upload_file($_FILES['upload_file']['name'], FILES_DIR.'/'.$path.'/', $_FILES['upload_file']['tmp_name'], $overwrite);<br />
			$clean_file_name = preg_replace('/ /', '_', $_FILES['upload_file']['name'] );<br />
			$clean_file_name = preg_replace('/[^A-Za-z0-9_.]/', '', $clean_file_name );</p>
<p>            $file = upload_file( $clean_file_name, FILES_DIR.'/'.$path.'/', $_FILES['upload_file']['tmp_name'], $overwrite);</p>
<p>            if ($file === false)<br />
               Flash::set('error', __('File has not been uploaded!'));<br />
        }<br />
        redirect(get_url('plugin/file_manager/browse/'.$path));<br />
    }<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://jamesborder.com/2009/09/wolf-cms-clean-uploaded-file-names/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Ternary Operator</title>
		<link>http://jamesborder.com/2009/07/the-ternary-operator/</link>
		<comments>http://jamesborder.com/2009/07/the-ternary-operator/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 14:17:28 +0000</pubDate>
		<dc:creator>me</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://jamesborder.com/?p=310</guid>
		<description><![CDATA[$variable = condition ? if true : if false; as in: $age = 24; $drinkingAge = ($age > 21) ? &#8220;have a beer&#8221; : &#8220;have an iced tea&#8221;; echo $drinkingAge; // returns have a beer]]></description>
			<content:encoded><![CDATA[<p>$variable = condition ? if true : if false; </p>
<p>as in:</p>
<p>$age = 24;<br />
$drinkingAge = ($age > 21) ? &#8220;have a beer&#8221; : &#8220;have an iced tea&#8221;;</p>
<p>echo $drinkingAge; // returns have a beer</p>
]]></content:encoded>
			<wfw:commentRss>http://jamesborder.com/2009/07/the-ternary-operator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP &#8211; date menus</title>
		<link>http://jamesborder.com/2009/06/php-date-menus/</link>
		<comments>http://jamesborder.com/2009/06/php-date-menus/#comments</comments>
		<pubDate>Fri, 05 Jun 2009 03:59:08 +0000</pubDate>
		<dc:creator>me</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://jamesborder.com/site/php_-_date_menus/#When:03:59:08Z</guid>
		<description><![CDATA[&#60;?php $today = getdate(); $day = $today[&#39;mday&#39;]; $month = $today[&#39;mon&#39;]; $year = $today[&#39;year&#39;]; $mtharr = array(&#8220;January&#8221;,&#8221;February&#8221;,&#8221;March&#8221;,&#8221;April&#8221;, &#8220;May&#8221;,&#8221;June&#8221;,&#8221;July&#8221;,&#8221;August&#8221;,&#8221;September&#8221;, &#8220;October&#8221;,&#8221;November&#8221;,&#8221;December&#8221;); ?&#62; &#60;select name=&#8221;start_day&#8221;> &#60;?php for ($i=1;$i&#60;=31;$i++) { echo &#8220;nt&#60;option value=&#8221;$i&#8221;"; if ($i == $day) echo &#8221; selected&#8221;; echo &#8220;>$i&#60;/option>&#8221;; } ?&#62; &#60;/select> &#60;select name=&#8221;start_month&#8221;> &#60;?php for ($i=1;$i&#60;=12;$i++) { echo &#8220;nt&#60;option value=&#8221;$i&#8221;"; if ($i == $month) echo &#8221; <a href='http://jamesborder.com/2009/06/php-date-menus/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>&lt;?php</p>
<p>	$today = getdate();</p>
<p>	$day = $today[&#39;mday&#39;];<br />
	$month = $today[&#39;mon&#39;];<br />
	$year = $today[&#39;year&#39;];<br />
	$mtharr = array(&#8220;January&#8221;,&#8221;February&#8221;,&#8221;March&#8221;,&#8221;April&#8221;,<br />
				&#8220;May&#8221;,&#8221;June&#8221;,&#8221;July&#8221;,&#8221;August&#8221;,&#8221;September&#8221;,<br />
				&#8220;October&#8221;,&#8221;November&#8221;,&#8221;December&#8221;);</p>
<p>?&gt;</p>
<p>&lt;select name=&#8221;start_day&#8221;> </p>
<p>&lt;?php</p>
<p>for ($i=1;$i&lt;=31;$i++) {</p>
<p>	echo &#8220;nt&lt;option value=&#8221;$i&#8221;"; </p>
<p>	if ($i == $day) echo &#8221; selected&#8221;;<br />
		echo &#8220;>$i&lt;/option>&#8221;; </p>
<p>}</p>
<p>?&gt;<br />
&lt;/select></p>
<p>&lt;select name=&#8221;start_month&#8221;><br />
&lt;?php</p>
<p>for ($i=1;$i&lt;=12;$i++) {</p>
<p>	echo &#8220;nt&lt;option value=&#8221;$i&#8221;";<br />
	if ($i == $month) echo &#8221; selected&#8221;;<br />
		echo &#8220;>&#8221; . $mtharr[$i&#45;1] . &#8220;&lt;/option>&#8221;; </p>
<p>}</p>
<p>?&gt; </p>
<p>&lt;/select></p>
<p>&lt;select name=&#8221;start_year&#8221;><br />
&lt;?php</p>
<p>for ($i=0;$i&lt;=9;$i++) {</p>
<p>	$tmp = $today[&#39;year&#39;] + $i;<br />
	echo &#8220;nt&lt;option value=&#8221;$tmp&#8221;";<br />
	if ($today[&#39;year&#39;] == $tmp) echo &#8221; selected&#8221;;<br />
		echo &#8220;>&#8221; . $tmp . &#8220;&lt;/option>&#8221;;</p>
<p>}</p>
<p>?&gt;</p>
<p>&lt;/select></p>
]]></content:encoded>
			<wfw:commentRss>http://jamesborder.com/2009/06/php-date-menus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP &#8211; Trim a string without breaking words</title>
		<link>http://jamesborder.com/2009/04/php-trim-a-string-without-breaking-words/</link>
		<comments>http://jamesborder.com/2009/04/php-trim-a-string-without-breaking-words/#comments</comments>
		<pubDate>Thu, 30 Apr 2009 16:00:42 +0000</pubDate>
		<dc:creator>me</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://jamesborder.com/site/php_-_trim_a_string_without_breaking_words/#When:16:00:42Z</guid>
		<description><![CDATA[neat_trim($your_text, 100); function neat_trim( $string, $n, $close = &#39;&#8230;&#39; ) { $len = strlen( $string ); if ($len > $n) { preg_match(&#39;/(.{&#39; . $n . &#39;}.*?)b/&#39;, $string, $matches); return rtrim($matches[1]) . $close; } else { return $string; } }]]></description>
			<content:encoded><![CDATA[<p>neat_trim($your_text, 100);</p>
<p>function neat_trim( $string, $n, $close = &#39;&#8230;&#39; ) {</p>
<p>   $len = strlen( $string );</p>
<p>   if ($len > $n) {<br />
       preg_match(&#39;/(.{&#39; . $n . &#39;}.*?)b/&#39;, $string, $matches);<br />
       return rtrim($matches[1]) . $close;<br />
   } else {<br />
       return $string;<br />
   }</p>
<p>}</p>
]]></content:encoded>
			<wfw:commentRss>http://jamesborder.com/2009/04/php-trim-a-string-without-breaking-words/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

