Jump to content

[SOLVED] Can an object create itself?


immanuelx2

Recommended Posts

For example:

 

class Post
{
  function __construct() {}
  
  function getRelatedPosts()
  {
    // get related posts through query
    while ($post = mysql_fetch_assoc($query))
    {
      $post = new Post();
      $post->getTitle;
    }
  }
}

 

Reason I ask is that I am having trouble getting it to output anything using the getRelated type function.

 

Or is there a better way of trying to accomplish something like this?

Link to comment
https://forums.phpfreaks.com/topic/167425-solved-can-an-object-create-itself/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.