Register Members List Search Today's Posts Mark Forums Read

Reply
 
Article Options
[How-To]Object Programming in PHP
Ziki
Join Date: Nov 2005
Posts: 2,704

It appears that I am still alive

by Ziki Ziki is offline 27 Mar 2007

Object Oriented Programming is the neat little thing you can see everywhere in vBulletin code using the syntax $vbulletin->function.It is basically a variable that contains functions or any code you like.

So the base of an object is to create the class which looks something like this:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Ok we now created a class which will hold the prefix of all functions so now we want to try adding a simple function,for instance:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

So now we created a function inside.Notice $this which will be later replaced by the name of the class.

But when you would try to echo it it would give you an error that the function is a non-object.For that we have to construct the actual object:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

new indicates that we created a new object.So now we can use $nameofclass->plus(2, 9) which will output 11.Of course you can insert more functions.

This was a very short introduction to OOP.

Last edited by Ziki; 28 Mar 2007 at 19:18..
Views: 3101
Reply With Quote
Comments
  #2  
Old 30 Mar 2007, 21:28
budlight budlight is offline
 
Join Date: Mar 2007
I'm making an external script to post to a vBulletin forum. I pretty much need to do it an existing class. The problem is I need to require global.php within the class itself. This script errors when I move the require to inside the constructor. I have no clue why.

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Reply With Quote
  #3  
Old 27 Jun 2007, 11:34
YopY YopY is offline
 
Join Date: Aug 2006
imho, this article doesn't even begin to explain object-oriented programming in PHP.

@budlight, it would help if you copy / pasted the error here.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Article Options

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 16:15.

Layout Options | Width: Wide Color: