summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2013-09-02 00:00:22 +0200
committerEmiel Bruijntjes <emiel.bruijntjes@copernica.com>2013-09-02 00:00:22 +0200
commitbf4cc9a5e2c0a19f2099414b0a476402360fd9f8 (patch)
treec1ca4b66898601c95def18013c310589ad9c62bf /README.md
parentdee4b3660da27c5102fa62d4b6fdda2bcc2444bd (diff)
Update README.md
Diffstat (limited to 'README.md')
-rw-r--r--README.md40
1 files changed, 11 insertions, 29 deletions
diff --git a/README.md b/README.md
index f4b73a9..d468b07 100644
--- a/README.md
+++ b/README.md
@@ -7,42 +7,32 @@ extensions for PHP.
Unlike regular PHP extensions - which are really hard to implement and require a deep
knowledge of the Zend engine and pointer manipulation - extensions built with PHP-CPP
-are not difficult to developer at all. In fact, the only thing you need to do is write a function in
+are not difficult to develop at all. In fact, the only thing you need to do is write a function in
C++, and the PHP-CPP library uses all the power offered by C++11 to convert the parameters and return
values from your functions to/and from PHP:
-<code><pre>
-/**
- * Hello world function
- * @return std::string
- */
+<pre>
std::string hello_word()
{
return std::string("hello world!");
}
-</pre></code>
+</pre>
The function above is a native C++ function. With PHP-CPP you can export this function
to PHP with only one single C++ method call:
-<code><pre>
+<pre>
extension.function("hello_world", hello_world);
-</pre></code>
+</pre>
Working with parameters and return values is just as easy:
-<code><pre>
-/**
- * Function that takes parameters
- * @param int
- * @param int
- * @return int
- */
+<pre>
int my_plus(int a, int b)
{
return a+b;
}
-</pre></code>
+</pre>
The PHP-CPP library ensures that the variables
from PHP (which internally are complicated C structures), are automatically converted into
@@ -57,11 +47,7 @@ The return value of your function is also transformed by PHP-CPP into PHP.
More complicated structured can be handled by PHP-CPP as well. If you would like to return
a nested associative array from your function, you can do so too:
-<code><pre>
-/**
- * A C++ function that returns a nested PHP array
- * @return array
- */
+<pre>
PhpCpp::Value get_complex_array()
{
PhpCpp::Value r;
@@ -71,15 +57,11 @@ PhpCpp::Value get_complex_array()
r["c"][1] = "example";
return r;
}
-</pre></code>
+</pre>
The C++ function above is equivalent to the following function in PHP:
-<code></pre>
-/**
- * PHP alternative
- * @return array
- */
+<pre>
function get_complex_array()
{
return array(
@@ -88,7 +70,7 @@ function get_complex_array()
"c" => array("nested_value","example")
);
}
-</pre></code>
+</pre>
However, this library is currently a work in progress, and it is an open
source project. We are looking for people who'd like to contribute to it.