| eyebrow |
Package · Extension |
| lede |
The whole PHP surface of the ext-hello demo: one function that returns a fixed string. No arguments, no state, no side effects. |
| see_also |
| href |
meta |
../overview.md |
2 min |
|
| href |
meta |
../recipes/check-the-build.md |
3 min |
|
|
| prev |
| label |
href |
Overview |
../overview.md |
|
| next |
| label |
href |
Check that a package is built in |
../recipes/check-the-build.md |
|
The extension registers under the module name hello and adds a single global function.
Returns the string "hello from ext-hello package". It takes no arguments; passing any throws an
ArgumentCountError.
<?php
var_dump(bm_hello()); // string(28) "hello from ext-hello package"
A firmware built without the package has no bm_hello(). Guard optional use with function_exists() or
extension_loaded(), so the same script runs on both:
<?php
if (extension_loaded('hello')) {
echo bm_hello(), "\n";
} else {
echo "ext-hello is not built in\n";
}