Object Oriented Programming with PHP?

This is a discussion on "Object Oriented Programming with PHP?" within the PHP Forum section. This forum, and the thread "Object Oriented Programming with PHP? are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jan 18th, 2008, 22:30
JustinStudios's Avatar
SuperMember

SuperMember
Join Date: Mar 2007
Location: USA
Posts: 406
Blog Entries: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to JustinStudios
Object Oriented Programming with PHP?

I am being trained to write Java. It's wonderful! Now however, I am seeing this "Object Oriented PHP" and want to know, is it just like Java? I know the code is PHP, but do you just call an "Object" by using an include and let it run its course? If so, I am going to start doing this because it just makes more since than copying and pasting files from my library over and over again.

Anyone do OOP PHP? If so I'd love to hear tips and or comments!
Reply With Quote

  #2 (permalink)  
Old Jan 18th, 2008, 22:37
alexgeek's Avatar
Technical Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,770
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Re: Object Oriented Programming with PHP?

Not really like JAVA.
Less strict and yet restrictive.
You can' inherit multiple classes.
here is some pseudo code:
PHP: Select all

//php 4
class myclass {
//properties 
var $str "string";

//construct
function myclass() {
$this->helloworld();
}

//methods
function helloworld() {
echo 
"hello world";
}
}
$obj = new myclass(); //prints hello world
$obj->helloworld(); //same again 
Anything else you need to know?
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote
  #3 (permalink)  
Old Jan 18th, 2008, 22:46
JustinStudios's Avatar
SuperMember

SuperMember
Join Date: Mar 2007
Location: USA
Posts: 406
Blog Entries: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to JustinStudios
Re: Object Oriented Programming with PHP?

AHHHHHHHHHHHHHHHHHHHHHHHH! That is so fricken cool! I am so going to go learn how to do this!

couple of quick questions though:
1) Where do you store your classes? Can you make a file that has these that you can just import into any page that needs to access them?

2) Do you know where some "Good" resources for this are? Because google shows many resources but finding a good one is rough.
Reply With Quote
  #4 (permalink)  
Old Jan 18th, 2008, 22:49
alexgeek's Avatar
Technical Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,770
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Re: Object Oriented Programming with PHP?

1. Depends on whether you are using PHP4 or PHP5.
If the former (and hopefully), then you can use the awesome fantastic magic function __autoload();
This function will automatically load the class if you haven't included it.
Google __autoload for more info.

2. I have a book but I did know of some good sites, I'll let you know soon.
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote
  #5 (permalink)  
Old Jan 19th, 2008, 03:12
JustinStudios's Avatar
SuperMember

SuperMember
Join Date: Mar 2007
Location: USA
Posts: 406
Blog Entries: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to JustinStudios
Re: Object Oriented Programming with PHP?

Sweet! Thanks.. I posted this when you were online because I noticed you mention something about OOP PHP a while back in a post.
Reply With Quote
  #6 (permalink)  
Old Jan 19th, 2008, 12:35
alexgeek's Avatar
Technical Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,770
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Re: Object Oriented Programming with PHP?

Yeah I love OO PHP!
Luke's OO PHP article should help.
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote
  #7 (permalink)  
Old Jan 19th, 2008, 18:30
JustinStudios's Avatar
SuperMember

SuperMember
Join Date: Mar 2007
Location: USA
Posts: 406
Blog Entries: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to JustinStudios
Re: Object Oriented Programming with PHP?

Nice article. Wow, one found in the webforumz newsletter even.. maybe I should read that thing! haha, thanks again!
Reply With Quote
  #8 (permalink)  
Old Jan 20th, 2008, 00:57
alexgeek's Avatar
Technical Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,770
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Re: Object Oriented Programming with PHP?

You may like this thread also Classes in PHP
And the newsletter is awesome!
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote
  #9 (permalink)  
Old Jan 20th, 2008, 01:38
JustinStudios's Avatar
SuperMember

SuperMember
Join Date: Mar 2007
Location: USA
Posts: 406
Blog Entries: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to JustinStudios
Re: Object Oriented Programming with PHP?

I started off on the Newsletter team working on a CMS for it, but business picked up that month and I just ran out of time. I believe you were my replacement :P.
Reply With Quote
  #10 (permalink)  
Old Jan 20th, 2008, 11:25
alexgeek's Avatar
Technical Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,770
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Re: Object Oriented Programming with PHP?

Quote:
Originally Posted by JustinStudios View Post
I started off on the Newsletter team working on a CMS for it, but business picked up that month and I just ran out of time. I believe you were my replacement :P.
Yeah, so far I've managed to create half of 3 CMSs. This one we're working on now should work though
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote
Reply

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Recursive programming in php masha PHP Forum 4 Oct 1st, 2007 12:37
programming-designs.com programming-designs Free Web Site Critique 5 Aug 27th, 2006 19:31
ASP/SQL programming help squashed_Frog Classic ASP 3 May 15th, 2006 03:49
Dynamic Database oriented menu arora.a ASP.NET Forum 3 Feb 27th, 2006 13:16
NewBie to Web Programming ruwanr Introduce Yourself 7 Dec 1st, 2005 20:32


All times are GMT. The time now is 11:33.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43