Help Center/ FunctionGraph/ Developer Guide/ PHP/ PHP Function Template
Updated on 2025-12-10 GMT+08:00

PHP Function Template

The following is a sample code template of a PHP function:

<?php
/*function initializer($context) {
    $output = 'hello Initializer';
    return $output;
}*/ 
function handler($event, $context) {
    $output = array(
        "statusCode" => 200,
        "headers" => array(
            "Content-Type" => "application/json",
        ),
        "isBase64Encoded" => false,
        "body" => json_encode($event),
    );
    return $output;
}
?>

When you create an empty PHP event function on the FunctionGraph console, the preceding sample code is deployed by default.