mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-15 08:28:54 +00:00
Fix syntax errors in examples (#1504)
This commit is contained in:
parent
14a60fad6e
commit
73fae4ee51
31 changed files with 72 additions and 67 deletions
|
@ -385,7 +385,7 @@ $pkey = openssl_pkey_new();
|
|||
openssl_pkey_export($pkey, 'secret passphrase');
|
||||
|
||||
$spkac = openssl_spki_new($pkey, 'challenge string');
|
||||
$challenge = openssl_spki_export_challenge($spkac):
|
||||
$challenge = openssl_spki_export_challenge($spkac);
|
||||
echo $challenge;
|
||||
?>
|
||||
]]>
|
||||
|
|
|
@ -129,7 +129,7 @@
|
|||
<?php
|
||||
$sql = "insert into olympic (host_year,host_nation,host_city,"
|
||||
. "opening_date,closing_date) values (2008, 'China', 'Beijing',"
|
||||
. "to_date('08-08-2008','mm-dd- yyyy'),to_date('08-24-2008','mm-dd-yyyy')) ;"
|
||||
. "to_date('08-08-2008','mm-dd- yyyy'),to_date('08-24-2008','mm-dd-yyyy')) ;";
|
||||
$result = cubrid_execute($cubrid_con, $sql);
|
||||
if ($result) {
|
||||
/**
|
||||
|
|
|
@ -189,7 +189,7 @@ if ($con) {
|
|||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$conn_url = "CUBRID:127.0.0.1:33000:demodb:dba::?login_timeout=100"
|
||||
$conn_url = "CUBRID:127.0.0.1:33000:demodb:dba::?login_timeout=100";
|
||||
$con = cubrid_connect_with_url ($conn_url);
|
||||
|
||||
if ($con) {
|
||||
|
|
|
@ -165,7 +165,7 @@
|
|||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$conn_url = "CUBRID:127.0.0.1:33000:demodb:dba::"
|
||||
$conn_url = "CUBRID:127.0.0.1:33000:demodb:dba::";
|
||||
$con = cubrid_pconnect_with_url ($conn_url);
|
||||
|
||||
if ($con) {
|
||||
|
@ -191,7 +191,7 @@ if ($con) {
|
|||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$conn_url = "CUBRID:127.0.0.1:33000:demodb:dba::?althost=10.34.63.132:33088&rctime=100"
|
||||
$conn_url = "CUBRID:127.0.0.1:33000:demodb:dba::?althost=10.34.63.132:33088&rctime=100";
|
||||
$con = cubrid_pconnect_with_url ($conn_url);
|
||||
|
||||
if ($con) {
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
<![CDATA[
|
||||
<?php
|
||||
// Create cURL handles
|
||||
$ch1 = curl_init("http://example.com"/);
|
||||
$ch1 = curl_init("http://example.com/");
|
||||
$ch2 = curl_init("http://php.net/");
|
||||
|
||||
// Create a cURL multi handle
|
||||
|
|
|
@ -118,7 +118,7 @@ int(10)
|
|||
<?php
|
||||
$map = new \Ds\Map(["a" => 1, "b" => 2, "c" => 3]);
|
||||
|
||||
var_dump($map["a"])); // 1
|
||||
var_dump($map["a"]); // 1
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
|
|
@ -163,7 +163,7 @@ while (true) {
|
|||
case EXP_EOF:
|
||||
break 2; // break both the switch statement and the while loop
|
||||
default:
|
||||
die "Error has occurred!";
|
||||
die("Error has occurred!");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -128,8 +128,8 @@ $client->setCompleteCallback("reverse_complete");
|
|||
|
||||
# Add some tasks for a placeholder of where to put the results
|
||||
$results = array();
|
||||
$client->addTask("reverse", "Hello World!", &$results, "t1");
|
||||
$client->addTask("reverse", "!dlroW olleH", &$results, "t2");
|
||||
$client->addTask("reverse", "Hello World!", $results, "t1");
|
||||
$client->addTask("reverse", "!dlroW olleH", $results, "t2");
|
||||
|
||||
$client->runTasks();
|
||||
|
||||
|
|
|
@ -61,8 +61,8 @@
|
|||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$m1 = imageaffinematrixget(IMG_AFFINE_TRANSLATE, array('x' = 2, 'y' => 3));
|
||||
$m2 = imageaffinematrixget(IMG_AFFINE_SCALE, array('x' = 4, 'y' => 5));
|
||||
$m1 = imageaffinematrixget(IMG_AFFINE_TRANSLATE, array('x' => 2, 'y' => 3));
|
||||
$m2 = imageaffinematrixget(IMG_AFFINE_SCALE, array('x' => 4, 'y' => 5));
|
||||
$matrix = imageaffinematrixconcat($m1, $m2);
|
||||
print_r($matrix);
|
||||
?>
|
||||
|
|
|
@ -53,7 +53,7 @@ $img->scaleImage(400, 800);
|
|||
$size = $img->getSize();
|
||||
print_r($size);
|
||||
|
||||
echo "$img->getImageWidth()."x".$img->getImageHeight();
|
||||
echo $img->getImageWidth()."x".$img->getImageHeight();
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
|
|
@ -511,41 +511,39 @@
|
|||
</example>
|
||||
|
||||
<example>
|
||||
<title>Helper functon to get an image silhouette <function>Imagick::morphology</function></title>
|
||||
<title>Helper function to get an image silhouette <function>Imagick::morphology</function></title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<?php
|
||||
private function getCharacterOutline() {
|
||||
function getCharacterOutline() {
|
||||
$imagick = new \Imagick(realpath("./images/character.png"));
|
||||
$character = new \Imagick();
|
||||
$character->newPseudoImage(
|
||||
$imagick->getImageWidth(),
|
||||
$imagick->getImageHeight(),
|
||||
"canvas:white"
|
||||
);
|
||||
$canvas = new \Imagick();
|
||||
$canvas->newPseudoImage(
|
||||
$imagick->getImageWidth(),
|
||||
$imagick->getImageHeight(),
|
||||
"canvas:black"
|
||||
);
|
||||
|
||||
$imagick = new \Imagick(realpath("./images/character.png"));
|
||||
$character = new \Imagick();
|
||||
$character->newPseudoImage(
|
||||
$imagick->getImageWidth(),
|
||||
$imagick->getImageHeight(),
|
||||
"canvas:white"
|
||||
);
|
||||
$canvas = new \Imagick();
|
||||
$canvas->newPseudoImage(
|
||||
$imagick->getImageWidth(),
|
||||
$imagick->getImageHeight(),
|
||||
"canvas:black"
|
||||
);
|
||||
|
||||
$character->compositeimage(
|
||||
$imagick,
|
||||
\Imagick::COMPOSITE_COPYOPACITY,
|
||||
0, 0
|
||||
);
|
||||
$canvas->compositeimage(
|
||||
$character,
|
||||
\Imagick::COMPOSITE_ATOP,
|
||||
0, 0
|
||||
);
|
||||
$canvas->setFormat('png');
|
||||
|
||||
return $canvas;
|
||||
}
|
||||
$character->compositeimage(
|
||||
$imagick,
|
||||
\Imagick::COMPOSITE_COPYOPACITY,
|
||||
0, 0
|
||||
);
|
||||
$canvas->compositeimage(
|
||||
$character,
|
||||
\Imagick::COMPOSITE_ATOP,
|
||||
0, 0
|
||||
);
|
||||
$canvas->setFormat('png');
|
||||
|
||||
return $canvas;
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
|
|
@ -122,13 +122,13 @@ $fmt = datefmt_create(
|
|||
IntlDateFormatter::GREGORIAN
|
||||
);
|
||||
echo 'Second parsed output is ' . datefmt_parse($fmt, 'Mittwoch, 20. Dezember 1989 16:00 Uhr GMT-08:00');
|
||||
?
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
&example.outputs;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
First parsed output is 630201600
|
||||
Second parsed output is 630201600
|
||||
]]>
|
||||
|
|
|
@ -70,7 +70,7 @@ $collection->createIndex(
|
|||
// ...
|
||||
|
||||
if ($collection->dropIndex('myindex')) {
|
||||
echo 'An index named 'myindex' was found, and dropped.';
|
||||
echo "An index named 'myindex' was found, and dropped.";
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
|
|
|
@ -46,7 +46,7 @@ $session->sql("CREATE TABLE addressbook.names(name text, age int)")->execute();
|
|||
$session->sql("INSERT INTO addressbook.names values ('John', 42), ('Sam', 33)")->execute();
|
||||
|
||||
$schema = $session->getSchema("addressbook");
|
||||
$table = $schema->getTable("names
|
||||
$table = $schema->getTable("names");
|
||||
|
||||
if ($table->isView()) {
|
||||
echo "This is a view.";
|
||||
|
|
|
@ -142,7 +142,7 @@ if (!$c) { // The original error wasn't 28001, or the password change failed
|
|||
}
|
||||
|
||||
// Use the connection $c
|
||||
...
|
||||
// ...
|
||||
|
||||
?>
|
||||
]]>
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
<?php
|
||||
|
||||
var_dump(SeasLog::getRequestID());
|
||||
var_dump(SeasLog::setRequestID('reqeust_id_test_'.time()))
|
||||
var_dump(SeasLog::setRequestID('reqeust_id_test_'.time()));
|
||||
var_dump(SeasLog::getRequestID());
|
||||
|
||||
?>
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
print_r( snmprealwalk('localhost', 'public', '.1.3.6.1.2.1.2.3.4.5') );
|
||||
|
||||
snmp_read_mib('./FOO-BAR-MIB.txt');
|
||||
print_r( snmprealwalk('localhost', 'public', 'FOO-BAR-MIB::someTable' );
|
||||
print_r( snmprealwalk('localhost', 'public', 'FOO-BAR-MIB::someTable') );
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
|
|
@ -86,7 +86,7 @@
|
|||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$nameOfSecondInterface = snmp2_get_next('localhost', 'public', 'IF-MIB::ifName.1';
|
||||
$nameOfSecondInterface = snmp2_get_next('localhost', 'public', 'IF-MIB::ifName.1');
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$nameOfSecondInterface = snmpgetnetxt('localhost', 'public', 'IF-MIB::ifName.1';
|
||||
$nameOfSecondInterface = snmpgetnetxt('localhost', 'public', 'IF-MIB::ifName.1');
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
<![CDATA[
|
||||
<?php
|
||||
$server = "serverName\sqlexpress";
|
||||
$connectionInfo = array( "Database"=>"dbName", "UID"=>"username", "PWD"=>"password" )
|
||||
$connectionInfo = array( "Database"=>"dbName", "UID"=>"username", "PWD"=>"password" );
|
||||
$conn = sqlsrv_connect( $server, $connectionInfo );
|
||||
|
||||
$stmt = sqlsrv_query( $conn, "SELECT * FROM Table_1");
|
||||
|
|
|
@ -98,7 +98,7 @@ exit(0);
|
|||
$vl = new VarnishLog;
|
||||
while(1) {
|
||||
$line = $vl->getLine();
|
||||
printf("%s %d %s", VarnishLog::getTagName($line['tag'], $line['id'],
|
||||
printf("%s %d %s", VarnishLog::getTagName($line['tag']), $line['id'],
|
||||
$line['data']);
|
||||
}
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@
|
|||
<term><varname>actions</varname></term>
|
||||
<listitem>
|
||||
<para>
|
||||
You can also define a action method in a separate PHP script by using
|
||||
You can also define an action method in a separate PHP script by using
|
||||
this property and <classname>Yaf_Action_Abstract</classname>.
|
||||
<example>
|
||||
<title>define action in a separate file</title>
|
||||
|
@ -122,7 +122,7 @@ class IndexController extends Yaf_Controller_Abstract {
|
|||
);
|
||||
|
||||
/* action method may have arguments */
|
||||
public indexAction($name, $id) {
|
||||
public function indexAction($name, $id) {
|
||||
/* $name and $id are unsafe raw data */
|
||||
assert($name == $this->getRequest()->getParam("name"));
|
||||
assert($id == $this->_request->getParam("id"));
|
||||
|
@ -138,8 +138,8 @@ class IndexController extends Yaf_Controller_Abstract {
|
|||
<![CDATA[
|
||||
<?php
|
||||
class DummyAction extends Yaf_Action_Abstract {
|
||||
/* a action class shall define this method as the entry point */
|
||||
public execute() {
|
||||
/* an action class shall define this method as the entry point */
|
||||
public function execute() {
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -72,8 +72,8 @@ class Bootstrap extends Yaf_Bootstrap_Abstract {
|
|||
<![CDATA[
|
||||
<?php
|
||||
|
||||
defined('APPLICATION_PATH') // APPLICATION_PATH will be used in the ini config file
|
||||
|| define('APPLICATION_PATH', __DIR__));
|
||||
defined('APPLICATION_PATH') // APPLICATION_PATH will be used in the ini config file
|
||||
|| define('APPLICATION_PATH', __DIR__);
|
||||
|
||||
$application = new Yaf_Application(APPLICATION_PATH.'/conf/application.ini');
|
||||
$application->bootstrap();
|
||||
|
|
|
@ -79,6 +79,7 @@ class UserInitPlugin extends Yaf_Plugin_Abstract {
|
|||
$response->setRedirect("http://yourdomain.com/login/");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
|
|
@ -51,8 +51,9 @@
|
|||
/**
|
||||
* Add a supervar route to Yaf_Router route stack
|
||||
*/
|
||||
Yaf_Dispatcher::getInstance()->getRouter()->addRoute("name",
|
||||
new Yaf_Route_Supervar("r"));
|
||||
Yaf_Dispatcher::getInstance()->getRouter()->addRoute(
|
||||
"name",
|
||||
new Yaf_Route_Supervar("r")
|
||||
);
|
||||
?>
|
||||
]]>
|
||||
|
|
|
@ -58,7 +58,7 @@ class Bootstrap extends Yaf_Bootstrap_Abstract{
|
|||
$router->addConfig(Yaf_Registry::get("config")->routes);
|
||||
/**
|
||||
* add a Rewrite route, then for a request uri:
|
||||
* http://***/product/list/22/foo
|
||||
* http://example.com/product/list/22/foo
|
||||
* will be matched by this route, and result:
|
||||
*
|
||||
* [module] =>
|
||||
|
@ -82,6 +82,7 @@ class Bootstrap extends Yaf_Bootstrap_Abstract{
|
|||
|
||||
$router->addRoute('dummy', $route);
|
||||
}
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
|
|
@ -76,6 +76,7 @@ class Bootstrap extends Yaf_Bootstrap_Abstract{
|
|||
public function __initPlugins(Yaf_Dispatcher $dispatcher) {
|
||||
$dispatcher->registerPlugin(new DummyPlugin());
|
||||
}
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
@ -87,11 +88,10 @@ class Bootstrap extends Yaf_Bootstrap_Abstract{
|
|||
<![CDATA[
|
||||
<?php
|
||||
class DummyPlugin extends Yaf_Plugin_Abstract {
|
||||
|
||||
public function routerShutdown(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response) {
|
||||
var_dump(Yaf_Dispatcher::getInstance()->getRouter()->getCurrentRoute());
|
||||
}
|
||||
?>
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
|
|
@ -63,6 +63,7 @@ class IndexController extends Yaf_Controller_Abstract {
|
|||
$this->getView()->assign("foo", "bar");
|
||||
$this->_view->assign( array( "key" => "value", "name" => "value"));
|
||||
}
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
@ -77,7 +78,7 @@ class IndexController extends Yaf_Controller_Abstract {
|
|||
</head>
|
||||
<body>
|
||||
<?php
|
||||
foreach ($this->_tpl_vars as $name => value) {
|
||||
foreach ($this->_tpl_vars as $name => $value) {
|
||||
echo $$name; // or echo $this->_tpl_vars[$name];
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -70,6 +70,7 @@ class IndexController extends Yaf_Controller_Abstract {
|
|||
//prevent the auto-render
|
||||
Yaf_Dispatcher::getInstance()->autoRender(FALSE);
|
||||
}
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
|
|
@ -54,6 +54,7 @@ class IndexController extends Yaf_Controller_Abstract {
|
|||
$this->getView()->clear("foo")->clear("bar"); // clear "foo" and "bar"
|
||||
$this->_view->clear(); //clear all assigned variables
|
||||
}
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
|
|
@ -60,6 +60,7 @@ class IndexController extends Yaf_Controller_Abstract {
|
|||
public function indexAction() {
|
||||
$this->getView()->foo = "bar"; // same as assign("foo", "bar");
|
||||
}
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
|
Loading…
Reference in a new issue