Skip to content

Latest commit

 

History

History
43 lines (34 loc) · 1.31 KB

php-api.md

File metadata and controls

43 lines (34 loc) · 1.31 KB
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

PHP API

The extension registers under the module name hello and adds a single global function.

bm_hello

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"

Checking it is there

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";
}