bourse stock
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

919 B

ScriptsPlugin simplifies writing short code scripts which can be easily reused (chained). It removes plugin overhead allowing script to be one-line command.

Using scripts

Before using any script, you need to load Scripts plugin, like so:

phpQuery::plugin('Scripts');
// or inside a chain
pq('li')->plugin('Scripts');

After that, any available script can be used thou script method.

print pq('div')->script('safe_print');

Writing scripts

Scripts are placed in /phpQuery/plugins/Scripts. Each script has it's own file. Each file has access to 4 variables:

  • $self Represents $this
  • $params Represents parameters passed to script() method (without script name)
  • $return If not null, will be used as method result
  • $config Content of config.php file By default each script returns $self aka $this.
Example script
$return = $self->find($params[0]);