|
Home
iRate! IceMelon IM Tutorials Headlines CoolSites PHP Functions |
|
Most Referenced Functions » google_pagerank() » preg_replace() » imagecreatefrompng() » site_pageranks() » imagepng() » imagedestroy() » imagestring() » imagecolorallocate() » htmlentities() » preg_match() » fopen() » header() » getimagesize() » preg_match_all() » session_start() » htmlspecialchars() » ob_start() » ob_flush() » strstr() » flush() » strpos() » setcookie() » str_replace() » array2vars() » nl2br() » preg_split() » ereg() » ereg_replace() » urlencode() » readgzfile() Become a sponsor for $15/month. Link is sitewide - PR5 homepage, 20+ PR4 pages, 90+ PR3 pages. Email dave[AT]icemelon[D0T]c0m. |
PHP Functions
Function: sql_regcase (PHP 3, PHP 4, PHP 5) sql_regcase -- Make regular expression for case insensitive matchDescriptionstring sql_regcase ( string string )Returns a valid regular expression which will match string , ignoring case. This expression is string with each alphabetic character converted to a bracket expression; this bracket expression contains that character's uppercase and lowercase form. Other characters remain unchanged.
Example 1. sql_regcase() example
<?php
echo sql_regcase("Foo - bar.");
?>
The above example will output: [Ff][Oo][Oo] - [Bb][Aa][Rr]. This can be used to achieve case insensitive pattern matching in products which support only case sensitive regular expressions. CXVII. runkit FunctionsIntroductionThe runkit extension provides means to modify constants, user-defined functions, and user-defined classes. It also provides for custom superglobal variables and embeddable sub-interpreters via sandboxing. Additional information such as new releases, downloads, source files, maintainer information, and a CHANGELOG, can be located here: http://pecl.php.net/package/runkit . This package is meant as a feature added replacement for the classkit package. When compiled with the --enable-runkit=classkit option to ./configure, it will export classkit compatible function definitions and constants. RequirementsModifying Constants, Functions, Classes, and Methods works with all releases of PHP 4 and PHP 5. No special requirements are necessary. Custom Superglobals are only available in PHP 4.2.0 or later. Sandboxing requires PHP 5.1.0 or later, or PHP 5.0.0 with a special TSRM patch applied. Regardless of which version of PHP is in use it must be compiled with the --enable-maintainer-zts option. See the README file in the runkit package for additional information. Custom SuperglobalsThe runkit.superglobal ini option may be set to a comma-separated list of variable names to be treated as superglobals. This value should be set in the systemwide php.ini file, but may work in perdir configuration contexts depending on your SAPI. Example 1. Custom Superglobals with runkit.superglobal=_FOO,_BAR in php.ini
<?php
function show_values() {
echo "Foo is $_FOO\n";
echo "Bar is $_BAR\n";
echo "Baz is $_BAZ\n";
}
$_FOO = 'foo';
$_BAR = 'bar';
$_BAZ = 'baz';
/* Displays foo and bar, but not baz */
show_values();
?>
Predefined ConstantsThe constants below are defined by this extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime. RUNKIT_IMPORT_FUNCTIONS ( integer ) runkit_import() flag indicating that normal functions should be imported from the specified file. RUNKIT_IMPORT_CLASS_METHODS ( integer )runkit_import() flag indicating that class methods should be imported from the specified file. RUNKIT_IMPORT_CLASS_CONSTS ( integer )runkit_import() flag indicating that class constants should be imported from the specified file. Note that this flag is only meaningful in PHP versions 5.1.0 and above. RUNKIT_IMPORT_CLASS_PROPS ( integer )runkit_import() flag indicating that class standard properties should be imported from the specified file. RUNKIT_IMPORT_CLASSES ( integer )runkit_import() flag representing a bitwise OR of the RUNKIT_IMPORT_CLASS_* constants. RUNKIT_IMPORT_OVERRIDE ( integer )runkit_import() flag indicating that if any of the imported functions, methods, constants, or properties already exist, they should be replaced with the new definitions. If this flag is not set, then any imported definitions which already exist will be discarded. RUNKIT_ACC_PUBLIC ( integer )PHP5 specific flag to runkit_method_add() RUNKIT_ACC_PROTECTED ( integer )PHP5 specific flag to runkit_method_add() RUNKIT_ACC_PRIVATE ( integer )PHP5 specific flag to runkit_method_add() CLASSKIT_ACC_PUBLIC ( integer )PHP5 specific flag to classkit_method_add() Only defined when classkit compatibility is enabled. CLASSKIT_ACC_PROTECTED ( integer )PHP5 specific flag to classkit_method_add() Only defined when classkit compatibility is enabled. CLASSKIT_ACC_PRIVATE ( integer )PHP5 specific flag to classkit_method_add() Only defined when classkit compatibility is enabled. CLASSKIT_AGGREGATE_OVERRIDE ( integer )PHP5 specific flag to classkit_import() Only defined when classkit compatibility is enabled. RUNKIT_VERSION ( string )Defined to the current version of the runkit package. CLASSKIT_VERSION ( string )Defined to the current version of the runkit package. Only defined when classkit compatibility is enabled. Table of Contents Runkit_Sandbox -- Runkit Sandbox Class -- PHP Virtual Machine runkit_class_adopt -- Convert a base class to an inherited class, add ancestral methods when appropriate runkit_class_emancipate -- Convert an inherited class to a base class, removes any method whose scope is ancestral runkit_constant_add -- Similar to define(), but allows defining in class definitions as well runkit_constant_redefine -- Redefine an already defined constant runkit_constant_remove -- Remove/Delete an already defined constant runkit_function_add -- Add a new function, similar to create_function() runkit_function_copy -- Copy a function to a new function name runkit_function_redefine -- Replace a function definition with a new implementation runkit_function_remove -- Remove a function definition runkit_function_rename -- Change a function's name runkit_import -- Process a PHP file importing function and class definitions, overwriting where appropriate runkit_lint_file -- Check the PHP syntax of the specified file runkit_lint -- Check the PHP syntax of the specified php code runkit_method_add -- Dynamically adds a new method to a given class runkit_method_copy -- Copies a method from class to another runkit_method_redefine -- Dynamically changes the code of the given method runkit_method_remove -- Dynamically removes the given method runkit_method_rename -- Dynamically changes the name of the given method runkit_sandbox_output_handler -- Specify a function to capture and/or process output from a runkit sandbox runkit_superglobals -- Return numerically indexed array of registered superglobals Runkit_Sandbox(no version information, might be only in CVS) Runkit_Sandbox -- Runkit Sandbox Class -- PHP Virtual MachineDescriptionInstantiating the Runkit_Sandbox class creates a new thread with its own scope and program stack. Using a set of options passed to the constructor, this environment may be restricted to a subset of what the primary interpreter can do and provide a safer environment for executing user supplied code. Note: Sandbox support (required for runkit_lint() , runkit_lint_file() , and the Runkit_Sandbox class) is only available with PHP 5.1 or specially patched versions of PHP 5.0 and requires that thread safety be enabled. See the README file included in the runkit package for more information. Constructorvoid Runkit_Sandbox::__construct ( [array options] )options is an associative array containing any combination of the special ini options listed below.
safe_mode If the outer script which is instantiating the Runkit_Sandbox class is configured with safe_mode = off , then safe_mode may be turned on for the sandbox environment. This setting can not be used to disable safe_mode when it's already enabled in the outer script. open_basediropen_basedir may be set to any path below the current setting of open_basedir . If open_basedir is not set within the global scope, then it is assumed to be the root directory and may be set to any location. allow_url_fopenLike safe_mode , this setting can only be made more restrictive, in this case by setting it to FALSE when it is previously set to TRUE disable_functionsComma separated list of functions to disable within the sandbox sub-interpreter. This list need not contain the names of the currently disabled functions, they will remain disabled whether listed here or not. disable_classesComma separated list of classes to disable within the sandbox sub-interpreter. This list need not contain the names of the currently disabled classes, they will remain disabled whether listed here or not. runkit.superglobalComma separated list of variables to be treated as superglobals within the sandbox sub-interpreter. These variables will be used in addition to any variables defined internally or through the global runkit.superglobal setting. Example 1. Instantiating a restricted sandbox
<?php
$options = array(
'safe_mode'=>true,
'open_basedir'=>'/var/www/users/jdoe/',
'allow_url_fopen'=>'false',
'disable_functions'=>'exec,shell_exec,passthru,system',
'disable_classes'=>'myAppClass');
$sandbox = new Runkit_Sandbox($options);
/* Non-protected ini settings may set normally */
$sandbox->ini_set('html_errors',true);
?>
Accessing VariablesAll variables in the global scope of the sandbox environment are accessible as properties of the sandbox object. The first thing to note is that because of the way memory between these two threads is managed, object and resource variables can not currently be exchanged between interpreters. Additionally, all arrays are deep copied and any references will be lost. This also means that references between interpreters are not possible. Example 2. Working with variables in a sandbox
<?php
$sandbox = new Runkit_Sandbox();
$sandbox->foo = 'bar';
$sandbox->eval('echo "$foo\n"; $bar = $foo . "baz";');
echo "{$sandbox->bar}\n";
if (isset($sandbox->foo)) unset($sandbox->foo);
$sandbox->eval('var_dump(isset($foo));');
?>
The above example will output: bar barbaz bool(false) Calling PHP FunctionsAny function defined within the sandbox may be called as a method on the sandbox object. This also includes a few pseudo-function language constructs: eval() , include() , include_once() , require() , require_once() , echo() , print() , die() , and exit() . Example 3. Calling sandbox functions
<?php
$sandbox = new Runkit_Sandbox();
echo $sandbox->str_replace('a','f','abc');
?>
The above example will output: fbc When passing arguments to a sandbox function, the arguments are taken from the outer instance of PHP. If you wish to pass arguments from the sandbox's scope, be sure to access them as properties of the sandbox object as illustrated above. Example 4. Passing arguments to sandbox functions
<?php
$sandbox = new Runkit_Sandbox();
$foo = 'bar';
$sandbox->foo = 'baz';
echo $sandbox->str_replace('a',$foo,'a');
echo $sandbox->str_replace('a',$sandbox->foo,'a');
?>
The above example will output: bar baz Related Function(s) |