<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: php code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sat, 26 Jul 2008 20:12:54 GMT</pubDate>
    <description>DZone Snippets: php code</description>
    <item>
      <title>Sample date calculations</title>
      <link>http://snippets.dzone.com/posts/show/4360</link>
      <description>&lt;code&gt;&lt;br /&gt;  Today: &lt;?php echo date('Y-m-d') ?&gt; &lt;br /&gt;&lt;br /&gt;  Tomorrow: &lt;?php echo date('Y-m-d', strtotime('+1 day')) ?&gt; &lt;br /&gt;&lt;br /&gt;  1 week later: &lt;?php echo date('Y-m-d', strtotime('+1 week')) ?&gt; &lt;br /&gt;&lt;br /&gt;  1 month later: &lt;?php echo date('Y-m-d', strtotime('+1 month')) ?&gt; &lt;br /&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 27 Jul 2007 06:07:38 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4360</guid>
      <author>stancell (Algimantas Stancelis)</author>
    </item>
    <item>
      <title>Get file extension</title>
      <link>http://snippets.dzone.com/posts/show/2776</link>
      <description>&lt;code&gt;&lt;br /&gt;function file_extension($filename)&lt;br /&gt;{&lt;br /&gt;    $path_info = pathinfo($filename);&lt;br /&gt;    return $path_info['extension'];&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 04 Oct 2006 09:09:14 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2776</guid>
      <author>stancell (Algimantas Stancelis)</author>
    </item>
    <item>
      <title>Emulate register_globals off</title>
      <link>http://snippets.dzone.com/posts/show/2723</link>
      <description>&lt;code&gt;&lt;br /&gt;function unregister_GLOBALS()&lt;br /&gt;{&lt;br /&gt;if (!ini_get('register_globals')) {&lt;br /&gt;       return;&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   // Might want to change this perhaps to a nicer error&lt;br /&gt;   if (isset($_REQUEST['GLOBALS']) || isset($_FILES['GLOBALS'])) {&lt;br /&gt;       die('GLOBALS overwrite attempt detected');&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   // Variables that shouldn't be unset&lt;br /&gt;   $noUnset = array('GLOBALS',  '_GET',&lt;br /&gt;                     '_POST',    '_COOKIE',&lt;br /&gt;                     '_REQUEST', '_SERVER',&lt;br /&gt;                     '_ENV',    '_FILES');&lt;br /&gt;&lt;br /&gt;   $input = array_merge($_GET,    $_POST,&lt;br /&gt;                         $_COOKIE, $_SERVER,&lt;br /&gt;                         $_ENV,    $_FILES,&lt;br /&gt;                         isset($_SESSION) &amp;&amp; is_array($_SESSION) ? $_SESSION : array());&lt;br /&gt;  &lt;br /&gt;   foreach ($input as $k =&gt; $v) {&lt;br /&gt;       if (!in_array($k, $noUnset) &amp;&amp; isset($GLOBALS[$k])) {&lt;br /&gt;           unset($GLOBALS[$k]);&lt;br /&gt;       }&lt;br /&gt;   }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;unregister_GLOBALS();&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Source: http://www.zend.com/manual/faq.misc.php#faq.misc.registerglobals</description>
      <pubDate>Wed, 27 Sep 2006 15:57:39 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2723</guid>
      <author>stancell (Algimantas Stancelis)</author>
    </item>
    <item>
      <title>Convert string to underscore_name</title>
      <link>http://snippets.dzone.com/posts/show/2681</link>
      <description>Converts "My House" to "my_house".&lt;br /&gt;Converts " Peter's nice car " to "peters_nice_car".&lt;br /&gt;Converts "_88" to "88"&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;function string_to_underscore_name($string)&lt;br /&gt;{&lt;br /&gt;    $string = preg_replace('/[\'"]/', '', $string);&lt;br /&gt;    $string = preg_replace('/[^a-zA-Z0-9]+/', '_', $string);&lt;br /&gt;    $string = trim($string, '_');&lt;br /&gt;    $string = strtolower($string);&lt;br /&gt;    &lt;br /&gt;    return $string;&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sat, 23 Sep 2006 17:52:55 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2681</guid>
      <author>stancell (Algimantas Stancelis)</author>
    </item>
    <item>
      <title>Check whether string begins with given string</title>
      <link>http://snippets.dzone.com/posts/show/2644</link>
      <description>Checks whether $string begins with $search&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;function string_begins_with($string, $search)&lt;br /&gt;{&lt;br /&gt;    return (strncmp($string, $search, strlen($search)) == 0);&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 22 Sep 2006 15:19:46 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2644</guid>
      <author>stancell (Algimantas Stancelis)</author>
    </item>
    <item>
      <title>string_ends_with</title>
      <link>http://snippets.dzone.com/posts/show/320</link>
      <description>&lt;code&gt;&lt;br /&gt;function string_ends_with($string, $ending)&lt;br /&gt;{&lt;br /&gt;    $len = strlen($ending);&lt;br /&gt;    $string_end = substr($string, strlen($string) - $len);&lt;br /&gt;   &lt;br /&gt;    return $string_end == $ending;&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 25 May 2005 07:02:20 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/320</guid>
      <author>stancell (Algimantas Stancelis)</author>
    </item>
    <item>
      <title>Pretty urls</title>
      <link>http://snippets.dzone.com/posts/show/319</link>
      <description>If url is 'index.php/hello' then $request will be 'hello'&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;$request = $_SERVER['PATH_INFO'];&lt;br /&gt;if (isset($request[0]) &amp;&amp; ($request[0] == '/')) {&lt;br /&gt;    $request = substr($request, 1);&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 25 May 2005 05:33:30 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/319</guid>
      <author>stancell (Algimantas Stancelis)</author>
    </item>
  </channel>
</rss>
