<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="https://www.webmaster-forums.net/crss/node/1044360" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title></title>
    <link>https://www.webmaster-forums.net/crss/node/1044360</link>
    <description></description>
    <language>en</language>
          <item>
    <title>JeevesBond wrote:

In PHP</title>
    <link>https://www.webmaster-forums.net/web-programming-and-application-development/beware-kittens-risk#comment-1243390</link>
    <description> &lt;p&gt;&lt;div class=&quot;quote-msg&quot;&gt;&lt;div class=&quot;quote-author&quot;&gt;&lt;em&gt;JeevesBond&lt;/em&gt; wrote:&lt;/div&gt;&lt;br /&gt;
&lt;blockquote&gt;
In PHP determining if an function already exists is done by calling &lt;code&gt;function_exists(&amp;#039;function_name&amp;#039;)&lt;/code&gt;. I don&#039;t believe it&#039;s a good idea to declare functions in multiple places though. :)&lt;/div&gt;&lt;/blockquote&gt;&lt;/p&gt;
&lt;p&gt;Indeed! Horrible Hack.&lt;/p&gt;
&lt;p&gt;One of my blocks already used the function and when the page which had my PHP on it was called it tried to define the same function which generated an error message about being unable to redefine the function.&lt;/p&gt;
&lt;p&gt;The quick fix was to change the name slightly, but, as you say, it&#039;s not good and I need to rewrite it so that it only defines the function if it hasn&#039;t been previously defined.&lt;/p&gt;
 </description>
     <pubDate>Sun, 12 Jul 2009 19:26:56 +0000</pubDate>
 <dc:creator>davecoventry</dc:creator>
 <guid isPermaLink="false">comment 1243390 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>At the moment I&#039;m giving the</title>
    <link>https://www.webmaster-forums.net/web-programming-and-application-development/beware-kittens-risk#comment-1243389</link>
    <description> &lt;blockquote&gt;&lt;p&gt;At the moment I&#039;m giving the function a slightly different name and defining it at the head of each instance.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Am not sure what the word &#039;instance&#039; means here. That does sound quite ghaslty though.&lt;/p&gt;
&lt;p&gt;In PHP determining if an function already exists is done by calling &lt;code&gt;function_exists(&amp;#039;function_name&amp;#039;)&lt;/code&gt;. I don&#039;t believe it&#039;s a good idea to declare functions in multiple places though. &lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/smile.png&quot; title=&quot;Smiling&quot; alt=&quot;Smiling&quot; class=&quot;smiley-content&quot; /&gt;&lt;/p&gt;
 </description>
     <pubDate>Sun, 12 Jul 2009 19:07:47 +0000</pubDate>
 <dc:creator>JeevesBond</dc:creator>
 <guid isPermaLink="false">comment 1243389 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>Still on namespaces; I&#039;ve</title>
    <link>https://www.webmaster-forums.net/web-programming-and-application-development/beware-kittens-risk#comment-1243386</link>
    <description> &lt;p&gt;Still on namespaces; I&#039;ve got a procedure that I use to push the results of my SQL query onto an array in a particular format.&lt;/p&gt;
&lt;p&gt;I use this same array in a number of instances.&lt;/p&gt;
&lt;p&gt;Is there a way I can check to see if the function is already defined?&lt;/p&gt;
&lt;p&gt;At the moment I&#039;m giving the function a slightly different name and defining it at the head of each instance. Obviously, this is not best practice...&lt;/p&gt;
 </description>
     <pubDate>Sun, 12 Jul 2009 07:44:47 +0000</pubDate>
 <dc:creator>davecoventry</dc:creator>
 <guid isPermaLink="false">comment 1243386 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>I would use variable_set()</title>
    <link>https://www.webmaster-forums.net/web-programming-and-application-development/beware-kittens-risk#comment-1243363</link>
    <description> &lt;p&gt;I would use &lt;a href=&quot;http://api.drupal.org/api/function/variable_set&quot;&gt;variable_set()&lt;/a&gt; and &lt;a href=&quot;http://api.drupal.org/api/function/variable_get&quot;&gt;variable_get()&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Then, assuming you&#039;re writing a module, put a call to &lt;a href=&quot;http://api.drupal.org/api/function/variable_del/6&quot;&gt;variable_del()&lt;/a&gt; into the module&#039;s &lt;a href=&quot;http://api.drupal.org/api/function/hook_uninstall/6&quot;&gt;hook_uninstall()&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;You could also use globals, just make sure they&#039;re appropriate for what you&#039;re trying to do. Globals can be evil if used improperly (naming collisions, functions unexpectedly changing their values and such). &lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/smile.png&quot; title=&quot;Smiling&quot; alt=&quot;Smiling&quot; class=&quot;smiley-content&quot; /&gt;&lt;/p&gt;
 </description>
     <pubDate>Fri, 10 Jul 2009 19:45:48 +0000</pubDate>
 <dc:creator>JeevesBond</dc:creator>
 <guid isPermaLink="false">comment 1243363 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>Right.
that&#039;s very</title>
    <link>https://www.webmaster-forums.net/web-programming-and-application-development/beware-kittens-risk#comment-1243362</link>
    <description> &lt;p&gt;Right.&lt;/p&gt;
&lt;p&gt;that&#039;s very useful.&lt;/p&gt;
&lt;p&gt;Thanks Greg.&lt;/p&gt;
 </description>
     <pubDate>Fri, 10 Jul 2009 19:17:00 +0000</pubDate>
 <dc:creator>davecoventry</dc:creator>
 <guid isPermaLink="false">comment 1243362 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>You could have a file that</title>
    <link>https://www.webmaster-forums.net/web-programming-and-application-development/beware-kittens-risk#comment-1243361</link>
    <description> &lt;p&gt;You could have a file that is included:&lt;/p&gt;
&lt;p&gt;davevars.php:&lt;br /&gt;
&lt;code&gt;$GLOBALS[&amp;#039;foo&amp;#039;] = array(&amp;#039;Stacks&amp;#039;,&amp;#039;of different&amp;#039;,&amp;#039;values&amp;nbsp; an&amp;#039;,&amp;#039;array);&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Then in your other code , do a&lt;br /&gt;
&lt;code&gt;require_once(&amp;#039;path/to/davevars.php&amp;#039;);&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;I use the $GLOBALS[&#039;foo&#039;] instead of just $foo, so that the include can be called from anywhere (even inside a function or class), and it will still be accessible everywhere.&lt;/p&gt;
&lt;p&gt;While outside of a classes/functions you can directly access it as $foo, I still prefer to do $GLOBAL[&#039;foo&#039;] so that later going back I know I&#039;m accessing something that would be used as a &quot;global&quot; value.&lt;/p&gt;
&lt;p&gt;-Greg&lt;/p&gt;
 </description>
     <pubDate>Fri, 10 Jul 2009 17:43:00 +0000</pubDate>
 <dc:creator>Greg K</dc:creator>
 <guid isPermaLink="false">comment 1243361 at https://www.webmaster-forums.net</guid>
  </item>
  </channel>
</rss>
