PHP Interop
Global Namespace
In order to access the PHP global namespace in Fep the PHP static class is used.
var array = [ 1, 2, 3 ];
var count = PHP::count array;
var name = "Cameron";
var replaced = PHP::str_replace( "C", "K", name );
Superglobals
PHP has a concept called superglobals: variables that are available in every scope. Fep discourages use of superglobals (it will use another approach). However, superglobals will be accessible via the PHP::SuperGlobal static class.
// In Example.php
$foo = "global";
// In Global.fep
require Example;
def testGlobal()
{
var foo = "local";
println format("foo in global context {foo}",
PHP::SuperGlobal::GLOBALS["foo"]);
println format("foo in local context {foo}", foo);
}
// A form is submitted with an input named "Name".
var name = PHP::SuperGlobal::_REQUEST["name"];