PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
spacebiscuit
Forum Contributor
Posts: 390 Joined: Mon Mar 07, 2005 3:20 pm
Post
by spacebiscuit » Thu Apr 07, 2011 8:04 am
Can someone let me know what the following code is doing:
Code: Select all
start_on = new DateTime($start_on);
$this->end_on = new DateTime($end_on);
Thanks,
Rob.
social_experiment
DevNet Master
Posts: 2793 Joined: Sun Feb 15, 2009 11:08 am
Location: .za
Post
by social_experiment » Thu Apr 07, 2011 9:35 am
It looks like objects are being instantiated
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
spacebiscuit
Forum Contributor
Posts: 390 Joined: Mon Mar 07, 2005 3:20 pm
Post
by spacebiscuit » Thu Apr 07, 2011 9:39 am
More specifically what does the '->' do/mean:
$this->end_on
Thanks,
Rob.
spacebiscuit
Forum Contributor
Posts: 390 Joined: Mon Mar 07, 2005 3:20 pm
Post
by spacebiscuit » Thu Apr 07, 2011 10:16 am
This is another example:
$sql is obviously a sql query
getInsertQuery is a function which I guess executes the query
but what is the purpose of:
Why not:
social_experiment
DevNet Master
Posts: 2793 Joined: Sun Feb 15, 2009 11:08 am
Location: .za
Post
by social_experiment » Thu Apr 07, 2011 11:25 am
$this-> is the way to refer to the classes' methods / properties inside the class (or other classes extending it).
Will not work because you cannot refer to the method (getInsertQuery()) in that manner inside the class.
robburne wrote: $sql is obviously a sql query
It's actually a variable containing probably a value (or resource, depending on the function) returned by
getInsertQuery()
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering