you can use callbacks (syntactically, similar to the way you do in javascript) in PHP 5.3+.
In earlier versions, depending on the specific goal, you might find call_user_func() or call_user_func_array() helpful. Certain functions include a callback parameter, as well (again, depends on what you're doing).
However, for what you're doing, there's no need. Your "psuedocode" is very close to actual code: it's a "conditional" code block, not a "callback."
edit: Also, you may notice that I used mysqli_* functions instead of mysql_*. ext/mysql is outdated; if you have any choice in the matter, you should not be using it. ext/mysqli or PDO are the recommended APIs for mysql.
How would you do a callback function in PHP? I know this is simple but I can't seem to figure it out.
Something like that.
Red
Someone should know this...
In earlier versions, depending on the specific goal, you might find call_user_func() or call_user_func_array() helpful. Certain functions include a callback parameter, as well (again, depends on what you're doing).
However, for what you're doing, there's no need.
Your "psuedocode" is very close to actual code: it's a "conditional" code block, not a "callback."
edit:
Also, you may notice that I used
mysqli_*functions instead ofmysql_*. ext/mysql is outdated; if you have any choice in the matter, you should not be using it. ext/mysqli or PDO are the recommended APIs for mysql.