3

I'm a complete beginner in learning PDO for PHP and I actually haven't learned MySQL or MySQLi yet.

(Please take a look at the code below) I'm trying to make sense of what this " -> " arrow means and I couldn't find an answer anywhere else. Is the arrow semantically equivalent to the action word "perform" in every day english?

E.G for the codes below, $stmt (perform) -> closeCursor();

Code:

$stmt = $db->prepare($sql);
$stmt->execute(array($title,$entry));
$stmt->closeCursor();

Thank you.

moto
  • 194
  • 3
  • 13

2 Answers2

12

The arrow is part of PHP's object syntax, it's saying:

$object->method();

In English is:

Run method on object

It's also used for accessing properties.

As PDO is a class in PHP and variables like $db are instances of that class, you're able to make use of the methods and properties in those instances.

Check out PHP's object docs for more info on the subject, and if you're new to Object Oriented programming then you'll need to research the subject.

dnagirl
  • 20,196
  • 13
  • 80
  • 123
Tom Walters
  • 15,366
  • 7
  • 57
  • 74
  • I guess you would recommend that I search up Object Oriented Programming and learn the intro to that and then try to make sense of PDO? – moto Mar 15 '13 at 17:57
  • Yep, PDO is based on the principals of OOP, and it's an excellent paradigm to understand for modern programming. – Tom Walters Mar 15 '13 at 18:04
0

That is php's object notation equivilent to . in Java and Javascript. Basically it's used to access a method or property of an object.

See the Objects and Classes documentation.

Marcel Korpel
  • 21,536
  • 6
  • 60
  • 80
prodigitalson
  • 60,050
  • 10
  • 100
  • 114