Page 1 of 1
ignore this post
Posted: Mon Feb 08, 2010 2:40 pm
by scarface222
removed
Re: For those of you with messy code...
Posted: Mon Feb 08, 2010 2:55 pm
by Eran
I would suggest against using this article as direct reference, as it uses PHP4 conventions which have been defunct for several years now (not surprisingly, the article is from 2002)
Re: For those of you with messy code...
Posted: Mon Feb 08, 2010 3:05 pm
by limitdesigns
Object-oriented programming isn't so much for performance as it is for organization and convenience. It's much easier to use OOP in large applications than it is to use only public functions.
Re: ignore this post
Posted: Mon Feb 08, 2010 5:33 pm
by scarface222
Thanks for your comments guys, especially pytrin as usual I will look into a later standard of oop. Well at least I learned not to use it haha. When you say old conventions pytrin, do you mean php tags like this <? ?> and such? Old syntax?
Re: ignore this post
Posted: Mon Feb 08, 2010 7:07 pm
by a.heresey
For starters, you name your constructors like this now:
Code: Select all
class Puppy{
public var $cute;
public var $good;
__construct($cuteness, $goodness){
$this->cute = $cuteness;
$this->good = $goodness;
}
and you can use the mysqli (my sql improved) object for connecting to the database
Code: Select all
$mysqli = new mysqli('localhost','username','password','database');
if (mysqli_connect_error()){
die("Connection Error (".mysqli_connect_errno().") ".mysqli_connect_error());
}
and you can designate properties and methods as private, protected, and public
and getters and setters are kinda controversial.
Other than that I think it was a really easy to understand tutorial.
This is my current fav OOP tutorial:
http://www.devshed.com/c/a/PHP/ObjectOr ... -Patterns/
Please post any good resources you find on OOP, as I am new to OOP too!
Re: ignore this post
Posted: Mon Feb 08, 2010 7:16 pm
by Eran
@heresey You shouldn't use 'var' with visibility keywords (public,protected,private), the latter are meant to replace the former.
@scarface, you can read all about PHP "new" OOP model in PHP5 in the manual -
http://php.net/manual/en/language.oop5.php
Some main changes:
- constructors / destructors
- method and member visibility
- magical methods (__get,__set, etc)
- scope resolution operator (::)
- much more
Re: ignore this post
Posted: Mon Feb 08, 2010 11:41 pm
by scarface222
alright thanks guys, appreciate the tips