From 159781ee8257329ca9c40306f7495a8c2f31f710 Mon Sep 17 00:00:00 2001 From: Emiel Bruijntjes Date: Fri, 14 Mar 2014 09:47:54 +0100 Subject: update documentation, added super.h and super.cpp files that I forgot in previous commit --- documentation/variables.html | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'documentation') 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;

Global variables

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.

@@ -305,7 +305,25 @@ std::cout << Php::GLOBALS["b"] << std::endl;

- 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. +

+

+


+// 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"];
+
+

+

Be careful with global C++ variables

+

+ 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 -- cgit v1.2.3