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
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 05-05-2005, 11:44 PM   #1 (permalink)
The Wanderer
 
Join Date: Apr 2005
Posts: 6
Thanks: 0
crash is on a distinguished road
Default Request : OOP Help

I am trying to learn OOP with PHP4, however my book dosnt explain it well - It just gives you alot of examples of OOP scripts without explaining anything.

So could someone make an example of an OOP script and explain everything (that includes $this-> whatever that does :)).
crash is offline  
Reply With Quote
Old 05-06-2005, 05:49 AM   #2 (permalink)
The Acquainted
 
Join Date: Mar 2005
Posts: 177
Thanks: 0
CreativeLogic is on a distinguished road
Default

Are you looking for PHP help in PHP4 or PHP5?
CreativeLogic is offline  
Reply With Quote
Old 05-08-2005, 01:21 AM   #3 (permalink)
The Wanderer
Newcomer 
 
Join Date: May 2005
Posts: 5
Thanks: 0
zeromancer is on a distinguished road
Default

OOP was completely redesigned in PHP 5. I would suggest upgrading to the most current version so you don't have to completely relearn everything when you move to PHP 5. The object structures were redesigned to have a much more java feel to them, complete with contructors and destructors, autoload, and much more predicatable behavior. but a VERY short tutorial follows for php 5:
PHP Code:
//class file
class myClass {
  
__constructor myCLass() {  //a constructor is executed when the class is initialized.
    
$this->name "default name";
  }

  function 
setName($newName) {
    
$this->name $newName;  //$this is a variable that should be used
  
}                           // when calling functions or variables from
                                         // within the class itself.
  
function getName() {
    return 
$this->name;
  }

  
__destructor killClass() {
    echo 
"Class is being destroyed.";
  }
}

//Inside your script

include("myClass.php");
$nameClass = new myClass(); //Initializes your new class.

echo $nameClass->getName(); // echos "Default Name"

$nameClass->setName("Steve");  //changes the name inside the class

echo $nameClass->getName();  // echos "Steve"

$nameClass->killClass();  //removes the class object from memory. 
I should be around to help if you have any other questions. I'm in the process of learning the new PHP5 oop structure myself. luckily i have a pretty good book on the subject.
Send a message via AIM to zeromancer
zeromancer is offline  
Reply With Quote
Reply



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
phpBB MOD Request... I think its pretty cool! kunoSTAR General 1 06-09-2005 02:12 AM


All times are GMT. The time now is 01:58 PM.

 
     

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