Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Plugin Hooks for a PHP application
blueparukia Offline
Junior Member
**
Posts: 35
Joined: Jan 2008
Post: #11
RE: Plugin Hooks for a PHP application
I can understand that fine - you use it as an aray kinda thing, and make each value a function. I rarely use foreach, but I have used it before and understand it.

Sessions and regexp are all I have trouble with. I think my main problem with this was I asked about 5 coders on MSN, plus hre and on another forum, and each person told me different ways to do things, so I got confused.

Anyway, thanks a tonne - and for $var() - never knew that was possible.

BP
02-17-2008 11:02 AM
Find all posts by this user
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #12
RE: Plugin Hooks for a PHP application
It doesn't really matter how you call the function.  $var() is the easiest, but call_* whatever works, as well as eval().

My Blog
02-17-2008 12:21 PM
Find all posts by this user
blueparukia Offline
Junior Member
**
Posts: 35
Joined: Jan 2008
Post: #13
RE: Plugin Hooks for a PHP application
You get an error when the hook has not been added, I fixed this with:

PHP Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
class plugins{
function add_hook($hook, $function)
{
 global $hooks;
 $hooks[$hook][] = $function;
}

function run_hooks($hook)
{
	global $hooks;
if(!is_array($hooks[$hook])){}
else{
foreach($hooks[$hook] as $function) 
{
$function();
}
}
}
}
?>

(This post was last modified: 02-17-2008 02:14 PM by blueparukia.)
02-17-2008 02:14 PM
Find all posts by this user
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #14
RE: Plugin Hooks for a PHP application
I don't think it produces an error?  Thought it would produce a "Notice".

If you didn't change the error reporting level, then yes, you'd have to add that check.

My Blog
02-17-2008 04:45 PM
Find all posts by this user
blueparukia Offline
Junior Member
**
Posts: 35
Joined: Jan 2008
Post: #15
RE: Plugin Hooks for a PHP application
Well, it produces a "Warning", yeah. Either way, that way works, so I;m happy Tongue
02-17-2008 04:48 PM
Find all posts by this user

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: