Follow me on twitter!Connections

Tag: operator

PHP References

by Steve Zahm on Sep.15, 2009, under PHP

I’m not quite sure how to use PHP references yet or why would one want to use them. They are declared by using the ampersand character (&). Here’s the PHP Manual link.

I’ve come across reference usage in a few WordPress plug-ins and even use it mine. This I kind of understand. The reference was being set on the $this variable within an object like so &$this. What this is doing is setting up a reference to the current object so you will be using the current object rather than creating a new instance of the object. So far I’ve only seen this used in the function parameter of a WordPress function within an object. Here’s an example using the activation hook:

register_activation_hook( dirname(__FILE__) . ‘/connections.php’, array(&$this, ‘activate’) );

The second parameter is normally where you would set the function name as a string to call when the plug-in is activated. If I understand correctly, since my plug-in is an object I’m setting up a reference to my plug-in and the function to call within the array. If anyone can clear this up for me it’d be very appreciated.

Leave a Comment :, more...

PHP Error Suppression

by Steve Zahm on Sep.15, 2009, under PHP

When I first started coding PHP (a mere 9 months ago) I came across the @ character preceding an expression. My Google skills are pretty good but I couldn’t find what this meant and why it might have been used. I guess I couldn’t find my answer because I wasn’t sure what question to ask. So if this helps anyone here’s a link to the PHP manual explaining the operator for error suppression.

NOTE: In my opinion this should be avoided.

Leave a Comment :, , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

What I'm Doing...

Posting tweet...