Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

PHP plugin system

Name: Anonymous 2007-01-22 1:41

So every PHP plugin system I've seen is OO.
Is there any way to make a plugin system using functions?

Name: Anonymous 2007-01-22 5:46

What do you mean by "plugin systems"?

There's nothing OO you can't do without OO, unless the language fails *cough*Java*cough*.

Name: Anonymous 2007-01-22 8:24

>>2
I recommend you get that cold checked out by a professional, you seem to be coughing up programming languages.

Name: Anonymous 2007-01-22 15:15

OO is superior.

Name: Anonymous 2007-01-22 15:22

OO is SUPERIOR
fixed

Name: Anonymous 2007-01-22 15:37

>>2
A system that for example, has places in the code where plugins can put their own code in.

index.php
<?php
hi();
?>

plugin.php
<?php
echo "hi";
?>

The hi() in index.php gets replaced with echo "hi" in plugin.php.

Name: Anonymous 2007-01-22 17:04

>>6

wrong

Name: Anonymous 2007-01-23 4:29

>>6
Simple "plugin" system:

<?php
function Plugin($plugin, $args) {
    extract $args;
    require "plugins/$plugin.php";
}
?>



How to use: You save that bit of code anywhere, and require it from your PHP code. Then you create "plugins" in the "plugins" subdirectory, an example of which would be this "greeting.php" plugin:

<?php
echo "Hello, $name";
?>



Whenever you want to call it, after you've required the first bit of code, you just do:

Plugin('greeting', array('name' => 'Pete'));

To pass arguments to plugins, define them in a dictionary like this. To use them from plugins, just use $xxx.

Name: Anonymous 2007-01-23 7:42

require_once require_once require_once require_once require_once require_once require_once require_once require_once require_once require_once require_once require_once require_once require_once require_once require_once require_once require_once require_once require_once require_once require_once require_once require_once require_once require_once require_once require_once require_once require_once require_once require_once require_once

Name: Anonymous 2007-01-23 11:10

>>9
You don't want require_once for that, moran. You may want to execute the plugin several times.

Name: Anonymous 2007-01-23 13:30

>>8

Good call.

Name: ​​​​​​​​​​ 2010-10-24 23:38

Name: Anonymous 2011-02-03 0:56

Name: Sgt.Kabu尭kiman놕痱 2012-05-28 21:55

Bringing /prog/ back to its people
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy

Don't change these.
Name: Email:
Entire Thread Thread List