diff options
author | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-03-14 09:47:54 +0100 |
---|---|---|
committer | Emiel Bruijntjes <emiel.bruijntjes@copernica.com> | 2014-03-14 09:47:54 +0100 |
commit | 159781ee8257329ca9c40306f7495a8c2f31f710 (patch) | |
tree | 4d465797f334e27a836c0c41b4aa82d4fe5586ab /documentation | |
parent | c9274ab3c422390998e628820afc6a27c12a1a57 (diff) |
update documentation, added super.h and super.cpp files that I forgot in previous commit
Diffstat (limited to 'documentation')
-rw-r--r-- | documentation/variables.html | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/documentation/variables.html b/documentation/variables.html index 6b63598..b3f4330 100644 --- a/documentation/variables.html +++ b/documentation/variables.html @@ -286,7 +286,7 @@ std::cout << array("Y-m-d H:i:s") << std::endl; <h2 id="global-variables">Global variables</h2> <p> To read or update global PHP variables, you can use the Php::GLOBALS - variable. This variable works more or less the same as the $_GLOBALS + variable. This variable works more or less the same as the $GLOBALS variable in a PHP script. </p> <p> @@ -305,7 +305,25 @@ std::cout << Php::GLOBALS["b"] << std::endl; </code></pre> </p> <p> - Unlike PHP scripts, that handles only single pageviews, an extension is + Next to the $GLOBALS variable, PHP allows you to access variables using + the $_GET, $_POST, $_COOKIE, $_FILES, $_SERVER, $_REQUEST and $_ENV variables. + In your C++ extension you can do something similar with the global variables + Php::GET, Php::POST, Php::COOKIE, Php::FILES, Php::SERVER, Php::REQUEST and + Php::ENV. These are global, read-only, objects with an overloaded operator[] + method. You can thus access them as if it were associative arrays. +</p> +<p> +<pre class="language-c++"><code> +// retrieve the value of a request variable +int age = Php::REQUEST["name"]; + +// or retrieve the value of a server variable +std::string referer = Php::SERVER["HTTP_REFERER"]; +</code></pre> +</p> +<h2 id="global-natives">Be careful with global C++ variables</h2> +<p> + Unlike PHP scripts, that only handle single pageviews, an extension is used to handle multiple pageviews after each other. This means that when you use global C++ (!) variables in your extension, that these variables are not set back to their initial value in between the pageviews. The |