TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 02-02-2009, 01:14 PM   #1 (permalink)
The Contributor
 
planepixel's Avatar
 
Join Date: Feb 2009
Posts: 28
Thanks: 10
planepixel is on a distinguished road
Default help with object code

hi I was reading php manual on object and classes and came across this code. i have no idea what this code is doing. i tried to figure it out but could not get anything from it.


PHP Code:
<?php
class db {
  
//...
  
private static $instance;
  
//...
  
public static function singleton() {
    if(!isset(
self::$instance)) {
      
// what is the purpose of following two lines
      
$c __CLASS__;
      
self::$instance = new $c();
      
// End of lines
    
}
    return 
self::$instance;
  }
  
//...
}
?>
the bold text is the main issue. could anybody please explain what this chunk of code is doing.
Thanks
planepixel is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using the Clone Construct to Clone an Object Wildhoney Advanced PHP Programming 5 01-29-2013 11:51 AM
Tips to Improve Your Coding and Projects Village Idiot Tips & Tricks 45 12-03-2012 07:46 AM
Writing Clean Code Village Idiot Tips & Tricks 10 06-25-2012 12:35 PM
Using the factory pattern (mad rantings of a mind without coffee) sketchMedia Advanced PHP Programming 35 09-25-2009 11:05 AM
Snipply.com - Code snippet website codyodell Show Off 27 04-13-2008 02:09 PM


All times are GMT. The time now is 09:46 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design