Skip to content

Latest commit

 

History

History
43 lines (34 loc) · 1.3 KB

php-api.md

File metadata and controls

43 lines (34 loc) · 1.3 KB
eyebrow ext-hello · PHP API
lede The whole PHP surface of ext-hello: one function that returns a fixed string. No arguments, no state, no side effects.
see_also
href meta
../overview.md
Overview
href meta
../recipes/check-the-build.md
Recipe
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 extension_loaded() or function_exists(), 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";
}