Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Stoimen Popov's Blog:
PHP: Don’t Call the Destructor Explicitly
Nov 16, 2011 @ 17:56:43

In this new post to his blog Stoimen Popov talks about calling the "destructor" method of an object and why doing it directly could lead to some issues - like not actually destroying the object before the script ends.

At the end of the script the interpreter frees the memory. Actually every object has a built-in destructor, just like it has built-in constructor. So even we don’t define it explicitly, the object has its destructor. Usually this destructor is executed at the end of the script, or whenever the object isn’t needed anymore. This can happen, for instance, at the end of a function body. Now if we call the destructor explicitly, which as I said I’ve seen many times, here’s what happen. As you can see calling the destructor explicitly doesn’t destroy the object. So the question is...how to destroy an object before the script stops?

He points out that one way to "destroy" an object is to null it out and remove the structure from memory. This is tricky, though, because a clone of the object will still exist in memory, just not the original.

tagged: destructor call directly null clone object

Link:

International PHP Magazine:
IPM Poll Question: Which is the Most Common PHP Database Problem?
Sep 06, 2006 @ 11:53:45

The International PHP Magazine has posted the results from their latest poll where they asked their readers "which is the most common PHP database problem?"

The options were:

  • Using MySQL directly
  • Not using auto-increment functionality
  • Using multiple databases
  • Not using relations
  • The n+1 pattern
And coming out on top (with 27.5%) was "Not using relations" in the SQL statements made. Following close behind was "Using MySQL directly" and falling in last was "Not using auto-increment functionality".

Be sure to vote in this week's poll that asks "Which is Truest?" - given several popular opinions on PHP, pick the one that you think is the most true.

tagged: poll most common database problem relations directly multiple poll most common database problem relations directly multiple

Link:

International PHP Magazine:
IPM Poll Question: Which is the Most Common PHP Database Problem?
Sep 06, 2006 @ 11:53:45

The International PHP Magazine has posted the results from their latest poll where they asked their readers "which is the most common PHP database problem?"

The options were:

  • Using MySQL directly
  • Not using auto-increment functionality
  • Using multiple databases
  • Not using relations
  • The n+1 pattern
And coming out on top (with 27.5%) was "Not using relations" in the SQL statements made. Following close behind was "Using MySQL directly" and falling in last was "Not using auto-increment functionality".

Be sure to vote in this week's poll that asks "Which is Truest?" - given several popular opinions on PHP, pick the one that you think is the most true.

tagged: poll most common database problem relations directly multiple poll most common database problem relations directly multiple

Link:


Trending Topics: