diff options
author | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-03-09 22:37:41 +0100 |
---|---|---|
committer | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-03-09 22:37:41 +0100 |
commit | 49d88d98a0656233f15923d31ea67a1ed229e514 (patch) | |
tree | 04bb753e4d5434c46bd90048e52d22260052334d /documentation | |
parent | bdca5b0454534413f10d13211885c086fafff35a (diff) |
work in progress on iterators
Diffstat (limited to 'documentation')
-rw-r--r-- | documentation/calling-functions-and-methods.html | 2 | ||||
-rw-r--r-- | documentation/exceptions.html | 9 | ||||
-rw-r--r-- | documentation/magic-methods-and-interfaces.html | 21 |
3 files changed, 22 insertions, 10 deletions
diff --git a/documentation/calling-functions-and-methods.html b/documentation/calling-functions-and-methods.html index 8e2e7ba..d3bc3e2 100644 --- a/documentation/calling-functions-and-methods.html +++ b/documentation/calling-functions-and-methods.html @@ -114,7 +114,7 @@ extern "C" { is used in the example to call the PHP method DateTime::format(). </p> <p> - In PHP scripts you can create an array with two members: and object and + In PHP scripts you can create an array with two members: an object and the name of a method. This array can then be used as if it was a regular function. You can do similar things in C++, as we showed in the example with the "time_format" variable. diff --git a/documentation/exceptions.html b/documentation/exceptions.html index f8af4d0..56e7a31 100644 --- a/documentation/exceptions.html +++ b/documentation/exceptions.html @@ -12,6 +12,11 @@ <p> <pre class="language-c++"><code>#include <phpcpp.h> +/** + * Simple function that takes two numeric parameters, + * and that divides them. Division by zero is of course + * not permitted - it will throw an exception then + */ Php::Value myDiv(Php::Parameters ¶ms) { // division by zero is not permitted, throw an exception when this happens @@ -75,7 +80,7 @@ exception caught </p> <h2>Catching exceptions in C++</h2> <p> - And this works the other way around too. If your extensions calls a PHP + And this works the other way around too. If your extension calls a PHP function, and that PHP function happens to throw an exception, you can catch it just as if it was a normal C++ exception. </p> @@ -111,7 +116,7 @@ extern "C" { be used just like a normal PHP $variable is used, and you can thus store integers, strings, objects, arrays, et cetera in it. But this also means that you can use it to store functions - because PHP variables can - be used to store function too! And that's exactly what we're doing here. + be used to store functions too! And that's exactly what we're doing here. </p> <p> The callMe() function from this example extension receives one single diff --git a/documentation/magic-methods-and-interfaces.html b/documentation/magic-methods-and-interfaces.html index 93c76a6..6ece6a5 100644 --- a/documentation/magic-methods-and-interfaces.html +++ b/documentation/magic-methods-and-interfaces.html @@ -159,11 +159,11 @@ echo(count($counter)."\n"); <p> A PHP object can be turned into a variable that behaves like an array by implementing the Php::ArrayAccess interface. When you do this, objects - can be accessed by with the array access operator ($object["property"]). + can be accessed with array access operators ($object["property"]). </p> <p> In the following example we use the Php::Countable and the Php::ArrayAccess - interfaces to create a class that acts like an associative array than can + interfaces to create an associative array class than can be used for storing strings (remember: this is just an example, PHP already has support for associative arrays, so it is debatable how useful the example is). @@ -278,10 +278,12 @@ extern "C" { to be forwarded to a regular C++ std::map object. </p> <p> - The Map object from the example does not have any regular methods at all. - It only implements the Php::Countable interface and Php::ArrayAccess interface, - so it is perfectly usable to store and retrieve properties, but it does not - have any methods. The following script shows how to use it. + Inside the get_module() function, the Map is registered and added to the + extension. But unlike many other examples, none of the class methods are + exported to PHP. It only implements the Php::Countable interface and + Php::ArrayAccess interface, so it is perfectly usable to store and retrieve + properties, but from a PHP script it does not have any callable methods. + The following script shows how to use it. </p> <p> <pre class="language-php"><code> @@ -292,7 +294,7 @@ $map = new Map(); // store some values $map["a"] = 1234; $map["b"] = "xyz"; -$map["c"] = new stdClass(); +$map["c"] = 0; // show the values echo($map["a"]."\n"); @@ -301,6 +303,11 @@ echo($map["c"]."\n"); // access a value that does not exist echo($map["d"]."\n"); + ?> </pre></code> </p> +<p> + The output speaks for itself. The map has three members, "1234" (a string + variable), "xyz" and "0". +</p> |