Tag: PHP
Renaming Classes – Finished
by Steve Zahm on Sep.16, 2009, under Connections
Well, I’ve finished renaming my PHP classes to make them a bit more unique as so to avoid conflicts with other plug-ins. I also scrubbed the code to make sure I’m using the same options instance throughout rather than creating a new instance of the class every time I needed it. I’m not certain, but I think that would cause less overhead.
Renaming Classes
by Steve Zahm on Sep.15, 2009, under Connections
Taking the time to rename all my classes to be a bit more unique to reduce the possibility of conflicting with another plug-in.
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.
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.