<?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>PHP Help</title>
	<atom:link href="http://phpmagister.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://phpmagister.com</link>
	<description>need php help?</description>
	<lastBuildDate>Thu, 26 Jan 2012 11:00:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>RegEx: Compare two strings to find Alliteration and Assonance</title>
		<link>http://phpmagister.com/regex-compare-two-strings-to-find-alliteration-and-assonance-7299/</link>
		<comments>http://phpmagister.com/regex-compare-two-strings-to-find-alliteration-and-assonance-7299/#comments</comments>
		<pubDate>Thu, 26 Jan 2012 11:00:00 +0000</pubDate>
		<dc:creator>Stacked</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[regex]]></category>

		<guid isPermaLink="false">http://phpmagister.com/regex-compare-two-strings-to-find-alliteration-and-assonance-7299/</guid>
		<description><![CDATA[<p>would be possible to Compare two strings to find Alliteration and Assonance?</p>
<p>i use mainly javascript or php</p>
 <a href="http://phpmagister.com/regex-compare-two-strings-to-find-alliteration-and-assonance-7299/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>would be possible to Compare two strings to find Alliteration and Assonance?</p>
<p>i use mainly javascript or php</p>
]]></content:encoded>
			<wfw:commentRss>http://phpmagister.com/regex-compare-two-strings-to-find-alliteration-and-assonance-7299/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why is a `switch` considered a looping structure for the purposes of `continue`?</title>
		<link>http://phpmagister.com/why-is-a-switch-considered-a-looping-structure-for-the-purposes-of-continue-7307/</link>
		<comments>http://phpmagister.com/why-is-a-switch-considered-a-looping-structure-for-the-purposes-of-continue-7307/#comments</comments>
		<pubDate>Thu, 26 Jan 2012 09:00:00 +0000</pubDate>
		<dc:creator>Stacked</dc:creator>
				<category><![CDATA[loops]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[switch-statement]]></category>

		<guid isPermaLink="false">http://phpmagister.com/why-is-a-switch-considered-a-looping-structure-for-the-purposes-of-continue-7307/</guid>
		<description><![CDATA[<p>I just got bit by assuming the following:</p>
<pre><code>foreach ($arr as $key =&#62; $value) {
  switch($key) {
    // ... some other cases
    default:
      continue;
      // ^== assumption: move on to the next iteration of the foreach
      //     actual PHP: treat</code></pre><p>&#8230;</p> <a href="http://phpmagister.com/why-is-a-switch-considered-a-looping-structure-for-the-purposes-of-continue-7307/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I just got bit by assuming the following:</p>
<pre><code>foreach ($arr as $key =&gt; $value) {
  switch($key) {
    // ... some other cases
    default:
      continue;
      // ^== assumption: move on to the next iteration of the foreach
      //     actual PHP: treat this continue just like a break
  }
  // ...
}
</code></pre>
<p>But in fact, according to the <a href="http://www.php.net/manual/en/control-structures.continue.php">documentation for continue</a>:</p>
<p>the switch statement is considered a looping structure for the purposes of <em>continue</em>.</p>
<p>Is there a reason for this choice on the part of PHP language designers? As far as I can tell, <code>switch</code> <em>isn&#8217;t</em> a looping control structure, so why treat it like one in this case?</p>
]]></content:encoded>
			<wfw:commentRss>http://phpmagister.com/why-is-a-switch-considered-a-looping-structure-for-the-purposes-of-continue-7307/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP money_format(); &#163; sign not GBP</title>
		<link>http://phpmagister.com/php-money_format-sign-not-gbp-7305/</link>
		<comments>http://phpmagister.com/php-money_format-sign-not-gbp-7305/#comments</comments>
		<pubDate>Thu, 26 Jan 2012 02:00:00 +0000</pubDate>
		<dc:creator>Stacked</dc:creator>
				<category><![CDATA[money-format]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://phpmagister.com/php-money_format-sign-not-gbp-7305/</guid>
		<description><![CDATA[<p>I cannot work out how to get the currency symbol?</p>
<p>At the moment I am using</p>
<pre><code>setlocale(LC_MONETARY, 'en_GB');
money_format('%i', 1000);
</code></pre>
<p>Which give me the output</p>
<pre><code>GBP1,000
</code></pre>
<p>But I want</p>
<pre><code>£1,000
</code></pre>
<p>I have checked out the PHP manual&#8230;</p> <a href="http://phpmagister.com/php-money_format-sign-not-gbp-7305/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I cannot work out how to get the currency symbol?</p>
<p>At the moment I am using</p>
<pre><code>setlocale(LC_MONETARY, 'en_GB');
money_format('%i', 1000);
</code></pre>
<p>Which give me the output</p>
<pre><code>GBP1,000
</code></pre>
<p>But I want</p>
<pre><code>£1,000
</code></pre>
<p>I have checked out the PHP manual but it isn&#8217;t that helpful.</p>
<p>Any ideas?</p>
<h4>Incoming search terms:</h4><ul><li>php gbp symbol in regex</li><li>php money_format uk gbp</li><li>php money_format uk pounds</li></ul><!-- SEO SearchTerms Tagging 2 Plugin -->]]></content:encoded>
			<wfw:commentRss>http://phpmagister.com/php-money_format-sign-not-gbp-7305/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Why are PHP errors printed twice?</title>
		<link>http://phpmagister.com/why-are-php-errors-printed-twice-7290/</link>
		<comments>http://phpmagister.com/why-are-php-errors-printed-twice-7290/#comments</comments>
		<pubDate>Wed, 25 Jan 2012 11:00:00 +0000</pubDate>
		<dc:creator>Stacked</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[php-errors]]></category>
		<category><![CDATA[php.ini]]></category>

		<guid isPermaLink="false">http://phpmagister.com/why-are-php-errors-printed-twice-7290/</guid>
		<description><![CDATA[<h3>Summary</h3>
<p>Amazingly I could find nothing about this on Google or SO. When I throw an exception in PHP it appears in my console twice, complete with error message and stack trace. The first time it&#8217;s printed it says &#8220;PHP&#8230;</p> <a href="http://phpmagister.com/why-are-php-errors-printed-twice-7290/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h3>Summary</h3>
<p>Amazingly I could find nothing about this on Google or SO. When I throw an exception in PHP it appears in my console twice, complete with error message and stack trace. The first time it&#8217;s printed it says &#8220;PHP Fatal error: &#8230;&#8221; and the second time it just says &#8220;Fatal error: &#8230;&#8221;. I haven&#8217;t tested this is the Apache plugin version.</p>
<h3>Example</h3>
<p>With some namespaces and paths shortened with &#8216;&#8230;&#8217; for safety:</p>
<pre>$ php code/com/.../tabular_data.php
PHP Fatal error:  Uncaught exception 'Exception' with message 'File type not supported' in /home/codemonkey/.../tabular_data.php:56
Stack trace:
#0 /home/codemonkey/.../tabular_data.php(88): com...Tabular_Data-&gt;loadFromFile('/home/codemonke...', false)
#1 /home/codemonkey/.../tabular_data.php(95): com...Tabular_Data::fromFile('/home/codemonke...')
#2 {main}
  thrown in /home/codemonkey/.../tabular_data.php on line 56

Fatal error: Uncaught exception 'Exception' with message 'File type not supported' in /home/codemonkey/.../tabular_data.php:56
Stack trace:
#0 /home/codemonkey/.../tabular_data.php(88): com...Tabular_Data-&gt;loadFromFile('/home/codemonke...', false)
#1 /home/codemonkey/.../tabular_data.php(95): com...Tabular_Data::fromFile('/home/codemonke...')
#2 {main}
  thrown in /home/codemonkey/.../tabular_data.php on line 56
</pre>
<h3>Question</h3>
<p>I assume it has something to do with stderr and stdout both printing the error. In any case how do I ask PHP nicely to only print it once, preferably to stderr?</p>
<hr />
<h3>Version output</h3>
<p>PHP 5.3.9 (cli) (built: Jan 11 2012 17:09:48)<br />
Copyright (c) 1997-2012 The PHP Group<br />
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies</p>
<h3>The code</h3>
<p><a href="http://pastebin.com/iBUGJ2eY" rel="nofollow">http://pastebin.com/iBUGJ2eY</a><br />
This is the exact code that displays double exceptions for me, with namespaces and paths edited to foos. Note that I always get double exceptions in the command line on this installation. I&#8217;m all but certain that the issue lies in the PHP configuration.</p>
]]></content:encoded>
			<wfw:commentRss>http://phpmagister.com/why-are-php-errors-printed-twice-7290/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL GROUP BY UNIX TIMESTAMP</title>
		<link>http://phpmagister.com/mysql-group-by-unix-timestamp-7286/</link>
		<comments>http://phpmagister.com/mysql-group-by-unix-timestamp-7286/#comments</comments>
		<pubDate>Wed, 25 Jan 2012 10:00:00 +0000</pubDate>
		<dc:creator>Stacked</dc:creator>
				<category><![CDATA[aggregate-functions]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://phpmagister.com/mysql-group-by-unix-timestamp-7286/</guid>
		<description><![CDATA[<p>I&#8217;m trying to fetch a number of rows from a MySQL database and group them by the day they were posted.</p>
<p>End result I would like the following..</p>
<p>Monday<br />
-Article 1<br />
-Article 2<br />
-Article 3</p>
<p>Tuesday<br />
-Article 1<br&#8230;</p> <a href="http://phpmagister.com/mysql-group-by-unix-timestamp-7286/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m trying to fetch a number of rows from a MySQL database and group them by the day they were posted.</p>
<p>End result I would like the following..</p>
<p>Monday<br />
-Article 1<br />
-Article 2<br />
-Article 3</p>
<p>Tuesday<br />
-Article 1<br />
-Article 2</p>
<p>Wednesday<br />
-Article 1<br />
-Article 2<br />
-Article 3<br />
-Article 4</p>
<p>And so on, I&#8217;m not sure if this can be done in MySQL alone without PHP doing extra work.</p>
<p>This is the query I have so far but doesn&#8217;t seem to group by day.</p>
<pre><code>SELECT
cms_news.news_id,
cms_news.news_title,
cms_news.news_date,
cms_news.news_category,
cms_news.news_source,
cms_news.news_type,
cms_news.news_content
FROM
cms_news cms_news,
GROUP BY
DAYOFMONTH(FROM_UNIXTIME(cms_news.news_date))
ORDER BY
cms_news.news_date DESC
</code></pre>
<p>Thanks.</p>
]]></content:encoded>
			<wfw:commentRss>http://phpmagister.com/mysql-group-by-unix-timestamp-7286/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>What is best practice when it comes to storing images for a gallery?</title>
		<link>http://phpmagister.com/what-is-best-practice-when-it-comes-to-storing-images-for-a-gallery-7287/</link>
		<comments>http://phpmagister.com/what-is-best-practice-when-it-comes-to-storing-images-for-a-gallery-7287/#comments</comments>
		<pubDate>Wed, 25 Jan 2012 09:00:00 +0000</pubDate>
		<dc:creator>Stacked</dc:creator>
				<category><![CDATA[apache]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[uploadify]]></category>

		<guid isPermaLink="false">http://phpmagister.com/what-is-best-practice-when-it-comes-to-storing-images-for-a-gallery-7287/</guid>
		<description><![CDATA[<p>My question is not about storing images on disk or in DB.</p>
<ul>
<li>Images will be stored on disk</li>
<li>Image path and other image data will be saved in database.</li>
<li>Images will be given a unique filename</li>
<li>Images will be</li></ul><p>&#8230;</p> <a href="http://phpmagister.com/what-is-best-practice-when-it-comes-to-storing-images-for-a-gallery-7287/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>My question is not about storing images on disk or in DB.</p>
<ul>
<li>Images will be stored on disk</li>
<li>Image path and other image data will be saved in database.</li>
<li>Images will be given a unique filename</li>
<li>Images will be stored in 3 sizes</li>
<li>In time there may be many images used by many users</li>
</ul>
<p>My questions are:<br />
- Should images be stored in one folder, or many folders?<br />
- Is it ok to use md5 for creating unique id&#8217;s? E.g. md5(id+filename+random_num)<br />
- Should images be cached on server or on clients browser / computer?  </p>
<p>Anything else I should think of?</p>
<p>The solution is using php, apache and mysql. We use Uploadify for uploading images.</p>
<p><strong>Some code I use today</strong>  </p>
<pre><code>  /**
   * Calculate dir tree for object
   * Folders starts from 00 to FF (HEX) and can have just as
   * many subfolders (I think <img src='http://phpmagister.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />
   * @param $id - User ID
   * @param $type - Image category
   * @return string
   */
  function calculateDirTree($id, $type)
  {
      $hashUserID   = substr(hash('md5', $id), -4);
      $parentFolder = substr($hashUserID,0,2);
      $subfolder    = substr($hashUserID,2);
      $basePath     = $type."/".$parentFolder.'/'.$subfolder.'/';

      return $basePath;
  }
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://phpmagister.com/what-is-best-practice-when-it-comes-to-storing-images-for-a-gallery-7287/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>vBulletin API to get member list and add member via PHP+cURL</title>
		<link>http://phpmagister.com/vbulletin-api-to-get-member-list-and-add-member-via-phpcurl-7275/</link>
		<comments>http://phpmagister.com/vbulletin-api-to-get-member-list-and-add-member-via-phpcurl-7275/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 03:00:00 +0000</pubDate>
		<dc:creator>Stacked</dc:creator>
				<category><![CDATA[api]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[vbulletin]]></category>

		<guid isPermaLink="false">http://phpmagister.com/vbulletin-api-to-get-member-list-and-add-member-via-phpcurl-7275/</guid>
		<description><![CDATA[<p>Looking to do two things with the vBulletin API (v4.1.3) via PHP+cURL:</p>
<p>Get member list.<br />
Add new user.</p>
<p>I am having a hard time finding any working examples of a php script which calls the API to do these&#8230;</p> <a href="http://phpmagister.com/vbulletin-api-to-get-member-list-and-add-member-via-phpcurl-7275/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Looking to do two things with the vBulletin API (v4.1.3) via PHP+cURL:</p>
<p>Get member list.<br />
Add new user.</p>
<p>I am having a hard time finding any working examples of a php script which calls the API to do these things. Thanks in advance.</p>
]]></content:encoded>
			<wfw:commentRss>http://phpmagister.com/vbulletin-api-to-get-member-list-and-add-member-via-phpcurl-7275/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to calculate the difference between two days as a formatted string?</title>
		<link>http://phpmagister.com/how-to-calculate-the-difference-between-two-days-as-a-formatted-string-7283/</link>
		<comments>http://phpmagister.com/how-to-calculate-the-difference-between-two-days-as-a-formatted-string-7283/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 02:00:00 +0000</pubDate>
		<dc:creator>Stacked</dc:creator>
				<category><![CDATA[date]]></category>
		<category><![CDATA[datemath]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://phpmagister.com/how-to-calculate-the-difference-between-two-days-as-a-formatted-string-7283/</guid>
		<description><![CDATA[<p>Here&#8217;s what I&#8217;ve got so far:</p>
<pre><code>/**
 * Parse a duration between 2 date/times in seconds
 * and to convert that duration into a formatted string
 *
 * @param integer $time_start start time in seconds
 * @param integer $time_end   end</code></pre><p>&#8230;</p> <a href="http://phpmagister.com/how-to-calculate-the-difference-between-two-days-as-a-formatted-string-7283/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s what I&#8217;ve got so far:</p>
<pre><code>/**
 * Parse a duration between 2 date/times in seconds
 * and to convert that duration into a formatted string
 *
 * @param integer $time_start start time in seconds
 * @param integer $time_end   end time in seconds
 * @param string  $format     like the php strftime formatting uses %y %m %w %d %h or %i.
 * @param boolean $chop       chop off sections that have 0 values
 */
public static function FormatDateDiff($time_start = 0, $time_end = 0, $format = "%s", $chop = false) {

        if($time_start &gt; $time_end) list($time_start, $time_end) = array($time_end, $time_start);

        list($year_start,$month_start,$day_start) = explode('-',date('Y-m-d',$time_start));
        list($year_end,$month_end,$day_end) = explode('-',date('Y-m-d',$time_end));

        $years = $year_end - $year_start;
        $months = $month_end - $month_start;
        $days = $day_start - $day_end;
        $weeks = 0;
        $hours = 0;
        $mins = 0;
        $secs = 0;

        if(mktime(0,0,0,$month_end,$day_end) &lt; mktime(0,0,0,$month_start,$day_start)) {
            $years -= 1;
        }
        if($days &lt; 0) {
            $months -= 1;
            $days += 30; // this is an approximation...not sure how to figure this out
        }
        if($months &lt; 0) $months += 12;
        if(strpos($format, '%y')===false) {
            $months += $years * 12;
        }
        if(strpos($format, '%w')!==false) {
            $weeks = floor($days/7);
            $days %= 7;
        }
        echo date('Y-m-d',$time_start).' to '.date('Y-m-d',$time_end).": {$years}y {$months}m {$weeks}w {$days}d&lt;br/&gt;";
}
</code></pre>
<p>(It&#8217;s incomplete <em>and</em> inaccurate)</p>
<p>I can&#8217;t seem to get the math right. Naively dividing it out won&#8217;t work because of leap years and differing lengths of months.</p>
<p>The logic also needs to change depending on the format string. For example, passing 04-Feb-2010 to 28-Jun-2011 (as unix timestamps) with format string <code>%y year %m month %d day</code> should output <code>1 year 4 month 24 day</code> but if <code>%y year</code> is omitted then it needs to add 12 months to the month, i.e., output should be <code>16 month 24 day</code>.</p>
<p>Should handle times too&#8230;but I haven&#8217;t got to that yet.</p>
<hr />
<p>None of these <a href="http://www.php.net/manual/en/dateinterval.format.php" rel="nofollow">date_diff</a> solutions handle <strong>weeks</strong>. And I don&#8217;t know how I could hack it into <code>date_diff</code>, so that&#8217;s not really a solution for me.</p>
<p>Furthermore, <code>$diff-&gt;format</code> doesn&#8217;t do what I asked&#8230;to give the total months and days if &#8220;bigger units&#8221; are omitted. Example:</p>
<pre><code>&gt;&gt;&gt; $start = new DateTime('04-Feb-2010')
&gt;&gt;&gt; $end = new DateTime('28-Jun-2011')
&gt;&gt;&gt; $diff = $start-&gt;diff($end)
&gt;&gt;&gt; $diff-&gt;format('%m months, %d days')
'4 months, 24 days'
</code></pre>
<p>Should be <code>16 months, 24 days</code>, as I stated earlier. Please stop being so quick to close my question as a dupe before you understand it fully. If the solutions to other questions can be tweaked to solve this, fine, but please explain how, because I don&#8217;t get it.</p>
<p>To be clear, </p>
<ul>
<li>if <code>%y</code> is omitted, years should be rolled in the months</li>
<li>if <code>%m</code> is omitted, months should be rolled into the days</li>
<li>if <code>%w</code> is omitted, weeks should be rolled into the days</li>
<li>if <code>%h</code> is omitted, hours should be rolled into minutes</li>
<li>if <code>%m</code> is omitted, minutes should be rolled into seconds</li>
</ul>
<p>If &#8220;smaller units&#8221; are omitted, the next biggest unit can be rounded or floored where it makes sense.</p>
]]></content:encoded>
			<wfw:commentRss>http://phpmagister.com/how-to-calculate-the-difference-between-two-days-as-a-formatted-string-7283/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Image Gallery System &#8211; Which Approach is Better?</title>
		<link>http://phpmagister.com/image-gallery-system-which-approach-is-better-7270/</link>
		<comments>http://phpmagister.com/image-gallery-system-which-approach-is-better-7270/#comments</comments>
		<pubDate>Mon, 23 Jan 2012 17:00:00 +0000</pubDate>
		<dc:creator>Stacked</dc:creator>
				<category><![CDATA[gallery]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://phpmagister.com/image-gallery-system-which-approach-is-better-7270/</guid>
		<description><![CDATA[<p>I am implementing an image upload system in PHP, The following are required:</p>
<ul>
<li>Have categories</li>
<li>Allow users to comment on images</li>
<li>Allow rating of images</li>
</ul>
<p>For that, I have 2 approaches in mind:</p>
<h2>1. Implement the categorization by</h2><p>&#8230;</p> <a href="http://phpmagister.com/image-gallery-system-which-approach-is-better-7270/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I am implementing an image upload system in PHP, The following are required:</p>
<ul>
<li>Have categories</li>
<li>Allow users to comment on images</li>
<li>Allow rating of images</li>
</ul>
<p>For that, I have 2 approaches in mind:</p>
<h2>1. Implement the categorization by folders</h2>
<p>Each category will have its own folder, and PHP will detect categories via those folders.</p>
<h3>Pros</h3>
<ul>
<li>Structured look, easily locatable images.</li>
<li>Use of native PHP functions to manipulate and collect information about folders and files</li>
</ul>
<h3>Cons</h3>
<ul>
<li>Multiple categorization is a pain</li>
<li>Need to save the full path in the database</li>
</ul>
<h2>2. Implement the categorization by database</h2>
<p>Each image in the database will have a catID (or multiple catIDs), and PHP will query the database to get the images</p>
<h3>Pros</h3>
<ul>
<li>Easily implemented multi-categories</li>
<li>Only image name is saved</li>
</ul>
<h3>Cons</h3>
<ul>
<li>Seems more messy</li>
<li>Need to query the database a lot.</li>
</ul>
<hr />
<p>Which do you think is better? Or is there a third, completely different, approach that I&#8217;m missing?</p>
<p>Just a note, I don&#8217;t need code, I can implement that myself, I&#8217;m looking to find what to implement.</p>
<p>Would love to hear from you.</p>
]]></content:encoded>
			<wfw:commentRss>http://phpmagister.com/image-gallery-system-which-approach-is-better-7270/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Is there a way to set the scope of require_once() explicitly to global?</title>
		<link>http://phpmagister.com/is-there-a-way-to-set-the-scope-of-require_once-explicitly-to-global-7271/</link>
		<comments>http://phpmagister.com/is-there-a-way-to-set-the-scope-of-require_once-explicitly-to-global-7271/#comments</comments>
		<pubDate>Mon, 23 Jan 2012 14:00:00 +0000</pubDate>
		<dc:creator>Stacked</dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://phpmagister.com/is-there-a-way-to-set-the-scope-of-require_once-explicitly-to-global-7271/</guid>
		<description><![CDATA[<p>I&#8217;m looking for a way to set the scope of <code>require_once()</code> to the global scope, when <code>require_once()</code> is used inside a function. Something like the following code should work:</p>
<p>file `foo.php&#8217;:</p>
<pre><code>&#60;?php

$foo = 42;
</code></pre>
<p>actual code:</p>
<pre><code>&#60;?php

function</code></pre><p>&#8230;</p> <a href="http://phpmagister.com/is-there-a-way-to-set-the-scope-of-require_once-explicitly-to-global-7271/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m looking for a way to set the scope of <code>require_once()</code> to the global scope, when <code>require_once()</code> is used inside a function. Something like the following code should work:</p>
<p>file `foo.php&#8217;:</p>
<pre><code>&lt;?php

$foo = 42;
</code></pre>
<p>actual code:</p>
<pre><code>&lt;?php

function includeFooFile() {
    require_once("foo.php"); // scope of "foo.php" will be the function scope
}

$foo = 23;

includeFooFile();
echo($foo."n"); // will print 23, but I want it to print 42.
</code></pre>
<p>Is there a way to explicitly set the scope of <code>require_once()</code>? Is there a nice workaround?</p>
]]></content:encoded>
			<wfw:commentRss>http://phpmagister.com/is-there-a-way-to-set-the-scope-of-require_once-explicitly-to-global-7271/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

