mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 17:08:54 +00:00
rearranged show_source to be in alphabetical order
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@31216 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
fd99113abd
commit
cee95e7fdc
1 changed files with 106 additions and 106 deletions
|
@ -60,7 +60,7 @@ echo $newfunc(2,M_E)."\n";
|
|||
<programlisting role="php">
|
||||
function process($var1, $var2, $farr) {
|
||||
for ($f=0; $f < count($farr); $f++)
|
||||
echo $farr[$f]($var1,$var2)."\n";
|
||||
echo $farr[$f]($var1,$var2)."\n";
|
||||
}
|
||||
|
||||
// create a bunch of math functions
|
||||
|
@ -82,7 +82,7 @@ process(2.3445, M_PI, $farr);
|
|||
// now make a bunch of string processing functions
|
||||
$garr = array(
|
||||
create_function('$b,$a','if (strncmp($a,$b,3) == 0) return "** \"$a\" '.
|
||||
'and \"$b\"\n** Look the same to me! (looking at the first 3 chars)";'),
|
||||
'and \"$b\"\n** Look the same to me! (looking at the first 3 chars)";'),
|
||||
create_function('$a,$b','; return "CRCs: ".crc32($a)." , ".crc32(b);'),
|
||||
create_function('$a,$b','; return "similar(a,b) = ".similar_text($a,$b,&$p)."($p%)";')
|
||||
);
|
||||
|
@ -120,10 +120,10 @@ print_r($av); // for PHP3 use var_dump()
|
|||
// outputs:
|
||||
// Array
|
||||
// (
|
||||
// [0] => the mango
|
||||
// [1] => a mango
|
||||
// [2] => that mango
|
||||
// [3] => this mango
|
||||
// [0] => the mango
|
||||
// [1] => a mango
|
||||
// [2] => that mango
|
||||
// [3] => this mango
|
||||
// )
|
||||
|
||||
// an array of strings ordered from shorter to longer
|
||||
|
@ -132,10 +132,10 @@ print_r($sv);
|
|||
// outputs:
|
||||
// Array
|
||||
// (
|
||||
// [0] => small
|
||||
// [1] => larger
|
||||
// [2] => a big string
|
||||
// [3] => it is a string thing
|
||||
// [0] => small
|
||||
// [1] => larger
|
||||
// [2] => a big string
|
||||
// [3] => it is a string thing
|
||||
// )
|
||||
|
||||
// sort it from longer to shorter
|
||||
|
@ -144,10 +144,10 @@ print_r($sv);
|
|||
// outputs:
|
||||
// Array
|
||||
// (
|
||||
// [0] => it is a string thing
|
||||
// [1] => a big string
|
||||
// [2] => larger
|
||||
// [3] => small
|
||||
// [0] => it is a string thing
|
||||
// [1] => a big string
|
||||
// [2] => larger
|
||||
// [3] => small
|
||||
// )
|
||||
</programlisting>
|
||||
</example>
|
||||
|
@ -485,7 +485,7 @@ function foo() {
|
|||
$numargs = func_num_args();
|
||||
echo "Number of arguments: $numargs<br>\n";
|
||||
if ($numargs >= 2) {
|
||||
echo "Second argument is: " . func_get_arg (1) . "<br>\n";
|
||||
echo "Second argument is: " . func_get_arg (1) . "<br>\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -537,11 +537,11 @@ function foo() {
|
|||
$numargs = func_num_args();
|
||||
echo "Number of arguments: $numargs<br>\n";
|
||||
if ($numargs >= 2) {
|
||||
echo "Second argument is: " . func_get_arg (1) . "<br>\n";
|
||||
echo "Second argument is: " . func_get_arg (1) . "<br>\n";
|
||||
}
|
||||
$arg_list = func_get_args();
|
||||
for ($i = 0; $i < $numargs; $i++) {
|
||||
echo "Argument $i is: " . $arg_list[$i] . "<br>\n";
|
||||
echo "Argument $i is: " . $arg_list[$i] . "<br>\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -684,7 +684,7 @@ foo (1, 2, 3); // Prints 'Number of arguments: 3'
|
|||
<?php
|
||||
function list_array ($array) {
|
||||
while (list ($key, $value) = each ($array)) {
|
||||
$str .= "<b>$key:</b> $value<br>\n";
|
||||
$str .= "<b>$key:</b> $value<br>\n";
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
@ -787,14 +787,14 @@ Mozilla/4.5 [en] (X11; U; Linux 2.2.9 i586)<hr>
|
|||
<?php
|
||||
$script = getenv ("PATH_TRANSLATED");
|
||||
if(!$script) {
|
||||
echo "<BR><B>ERROR: Script Name needed</B><BR>";
|
||||
echo "<BR><B>ERROR: Script Name needed</B><BR>";
|
||||
} else {
|
||||
if (ereg("(\.php|\.inc)$",$script)) {
|
||||
echo "<H1>Source of: $PATH_INFO</H1>\n<HR>\n";
|
||||
highlight_file($script);
|
||||
} else {
|
||||
echo "<H1>ERROR: Only PHP or include script names are allowed</H1>";
|
||||
}
|
||||
if (ereg("(\.php|\.inc)$",$script)) {
|
||||
echo "<H1>Source of: $PATH_INFO</H1>\n<HR>\n";
|
||||
highlight_file($script);
|
||||
} else {
|
||||
echo "<H1>ERROR: Only PHP or include script names are allowed</H1>";
|
||||
}
|
||||
}
|
||||
echo "<HR>Processed: ".date("Y/M/d H:i:s",time());
|
||||
?>
|
||||
|
@ -962,107 +962,107 @@ http://your.server.com/source/path/to/script.php
|
|||
<itemizedlist>
|
||||
<listitem>
|
||||
<simpara>
|
||||
a NUL-padded string
|
||||
a NUL-padded string
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
A SPACE-padded string
|
||||
A SPACE-padded string
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
h Hex string, low nibble first
|
||||
h Hex string, low nibble first
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
H Hex string, high nibble first
|
||||
H Hex string, high nibble first
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
c signed char
|
||||
c signed char
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
C unsigned char
|
||||
C unsigned char
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
s signed short (always 16 bit, machine byte order)
|
||||
s signed short (always 16 bit, machine byte order)
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
S unsigned short (always 16 bit, machine byte order)
|
||||
S unsigned short (always 16 bit, machine byte order)
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
n unsigned short (always 16 bit, big endian byte order)
|
||||
n unsigned short (always 16 bit, big endian byte order)
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
v unsigned short (always 16 bit, little endian byte order)
|
||||
v unsigned short (always 16 bit, little endian byte order)
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
i signed integer (machine dependent size and byte order)
|
||||
i signed integer (machine dependent size and byte order)
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
I unsigned integer (machine dependent size and byte order)
|
||||
I unsigned integer (machine dependent size and byte order)
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
l signed long (always 32 bit, machine byte order)
|
||||
l signed long (always 32 bit, machine byte order)
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
L unsigned long (always 32 bit, machine byte order)
|
||||
L unsigned long (always 32 bit, machine byte order)
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
N unsigned long (always 32 bit, big endian byte order)
|
||||
N unsigned long (always 32 bit, big endian byte order)
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
V unsigned long (always 32 bit, little endian byte order)
|
||||
V unsigned long (always 32 bit, little endian byte order)
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
f float (machine dependent size and representation)
|
||||
f float (machine dependent size and representation)
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
d double (machine dependent size and representation)
|
||||
d double (machine dependent size and representation)
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
x NUL byte
|
||||
x NUL byte
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
X Back up one byte
|
||||
X Back up one byte
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
@ NUL-fill to absolute position
|
||||
@ NUL-fill to absolute position
|
||||
</simpara>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
@ -1193,13 +1193,13 @@ $binarydata = pack ("nvc*", 0x1234, 0x5678, 65, 66);
|
|||
|
||||
$conn = odbc_connect ("webdb", "php", "chicken");
|
||||
$stmt = odbc_prepare ($conn,
|
||||
"UPDATE sessions SET data = ? WHERE id = ?");
|
||||
"UPDATE sessions SET data = ? WHERE id = ?");
|
||||
$sqldata = array (serialize($session_data), $PHP_AUTH_USER);
|
||||
if (!odbc_execute ($stmt, &$sqldata)) {
|
||||
$stmt = odbc_prepare($conn,
|
||||
"INSERT INTO sessions (id, data) VALUES(?, ?)");
|
||||
"INSERT INTO sessions (id, data) VALUES(?, ?)");
|
||||
if (!odbc_execute($stmt, &$sqldata)) {
|
||||
/* Something went wrong. Bitch, whine and moan. */
|
||||
/* Something went wrong. Bitch, whine and moan. */
|
||||
}
|
||||
}
|
||||
</programlisting>
|
||||
|
@ -1256,39 +1256,39 @@ error_reporting(FATAL + ERROR + WARNING);
|
|||
// error handler function
|
||||
function myErrorHandler ($errno, $errstr) {
|
||||
switch ($errno) {
|
||||
case FATAL:
|
||||
echo "<b>FATAL</b> [$errno] $errstr<br>\n";
|
||||
echo " Fatal error in line ".__LINE__." of file ".__FILE__;
|
||||
echo ", PHP ".PHP_VERSION." (".PHP_OS.")<br>\n";
|
||||
echo "Aborting...<br>\n";
|
||||
exit -1;
|
||||
break;
|
||||
case ERROR:
|
||||
echo "<b>ERROR</b> [$errno] $errstr<br>\n";
|
||||
break;
|
||||
case WARNING:
|
||||
echo "<b>WARNING</b> [$errno] $errstr<br>\n";
|
||||
break;
|
||||
default:
|
||||
echo "Unkown error type: [$errno] $errstr<br>\n";
|
||||
break;
|
||||
case FATAL:
|
||||
echo "<b>FATAL</b> [$errno] $errstr<br>\n";
|
||||
echo " Fatal error in line ".__LINE__." of file ".__FILE__;
|
||||
echo ", PHP ".PHP_VERSION." (".PHP_OS.")<br>\n";
|
||||
echo "Aborting...<br>\n";
|
||||
exit -1;
|
||||
break;
|
||||
case ERROR:
|
||||
echo "<b>ERROR</b> [$errno] $errstr<br>\n";
|
||||
break;
|
||||
case WARNING:
|
||||
echo "<b>WARNING</b> [$errno] $errstr<br>\n";
|
||||
break;
|
||||
default:
|
||||
echo "Unkown error type: [$errno] $errstr<br>\n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// function to test the error handling
|
||||
function scale_by_log ($vect, $scale) {
|
||||
if ( !is_numeric($scale) || $scale <= 0 )
|
||||
trigger_error("log(x) for x <= 0 is undefined, you used: scale = $scale",
|
||||
FATAL);
|
||||
trigger_error("log(x) for x <= 0 is undefined, you used: scale = $scale",
|
||||
FATAL);
|
||||
if (!is_array($vect)) {
|
||||
trigger_error("Incorrect input vector, array of values expected", ERROR);
|
||||
return null;
|
||||
trigger_error("Incorrect input vector, array of values expected", ERROR);
|
||||
return null;
|
||||
}
|
||||
for ($i=0; $i<count($vect); $i++) {
|
||||
if (!is_numeric($vect[$i]))
|
||||
trigger_error("Value at position $i is not a number, using 0 (zero)",
|
||||
WARNING);
|
||||
$temp[$i] = log($scale) * $vect[$i];
|
||||
if (!is_numeric($vect[$i]))
|
||||
trigger_error("Value at position $i is not a number, using 0 (zero)",
|
||||
WARNING);
|
||||
$temp[$i] = log($scale) * $vect[$i];
|
||||
}
|
||||
return $temp;
|
||||
}
|
||||
|
@ -1363,6 +1363,37 @@ Aborting...<br>
|
|||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<refentry id="function.show-source">
|
||||
<refnamediv>
|
||||
<refname>show_source</refname>
|
||||
<refpurpose>Syntax highlighting of a file</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>void <function>show_source</function></funcdef>
|
||||
<paramdef>string <parameter>filename</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<simpara>
|
||||
The <function>show_source</function> function prints out a syntax
|
||||
higlighted version of the code contained in <parameter>filename</parameter>
|
||||
using the colors defined in the built-in syntax highlighter for PHP.
|
||||
</simpara>
|
||||
<note>
|
||||
<simpara>
|
||||
This function is an alias for the function
|
||||
<function>highlight_file</function>
|
||||
</simpara>
|
||||
</note>
|
||||
<simpara>
|
||||
See also <function>highlight_string</function>,
|
||||
<function>highlight_file</function>.
|
||||
</simpara>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<refentry id="function.sleep">
|
||||
<refnamediv>
|
||||
<refname>sleep</refname>
|
||||
|
@ -1581,8 +1612,8 @@ if (!odbc_execute ($stmt, &$sqldata) || !odbc_fetch_into ($stmt, &$tmp))
|
|||
// we should now have the serialized data in $tmp[0].
|
||||
$session_data = unserialize ($tmp[0]);
|
||||
if (!is_array ($session_data)) {
|
||||
// something went wrong, initialize to empty array
|
||||
$session_data = array();
|
||||
// something went wrong, initialize to empty array
|
||||
$session_data = array();
|
||||
}
|
||||
}
|
||||
</programlisting>
|
||||
|
@ -1649,37 +1680,6 @@ if (!odbc_execute ($stmt, &$sqldata) || !odbc_fetch_into ($stmt, &$tmp))
|
|||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<refentry id="function.show-source">
|
||||
<refnamediv>
|
||||
<refname>show_source</refname>
|
||||
<refpurpose>Syntax highlighting of a file</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>void <function>show_source</function></funcdef>
|
||||
<paramdef>string <parameter>filename</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<simpara>
|
||||
The <function>show_source</function> function prints out a syntax
|
||||
higlighted version of the code contained in <parameter>filename</parameter>
|
||||
using the colors defined in the built-in syntax highlighter for PHP.
|
||||
</simpara>
|
||||
<note>
|
||||
<simpara>
|
||||
This function is an alias for the function
|
||||
<function>highlight_file</function>
|
||||
</simpara>
|
||||
</note>
|
||||
<simpara>
|
||||
See also <function>highlight_string</function>,
|
||||
<function>highlight_file</function>.
|
||||
</simpara>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
</reference>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
Loading…
Reference in a new issue