ignore this post
Moderator: General Moderators
-
scarface222
- Forum Contributor
- Posts: 354
- Joined: Thu Mar 26, 2009 8:16 pm
ignore this post
removed
Last edited by scarface222 on Mon Feb 08, 2010 5:38 pm, edited 2 times in total.
Re: For those of you with messy code...
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)
-
limitdesigns
- Forum Commoner
- Posts: 25
- Joined: Sat Feb 06, 2010 9:05 pm
Re: For those of you with messy code...
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.
-
scarface222
- Forum Contributor
- Posts: 354
- Joined: Thu Mar 26, 2009 8:16 pm
Re: ignore this post
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
For starters, you name your constructors like this now:
and you can use the mysqli (my sql improved) object for connecting to the database
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!
Code: Select all
class Puppy{
public var $cute;
public var $good;
__construct($cuteness, $goodness){
$this->cute = $cuteness;
$this->good = $goodness;
}
Code: Select all
$mysqli = new mysqli('localhost','username','password','database');
if (mysqli_connect_error()){
die("Connection Error (".mysqli_connect_errno().") ".mysqli_connect_error());
}
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
@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
@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
-
scarface222
- Forum Contributor
- Posts: 354
- Joined: Thu Mar 26, 2009 8:16 pm
Re: ignore this post
alright thanks guys, appreciate the tips