<?php $br = php_sapi_name() == "cli" ? "\n" : "<br>\n"; $module = 'forp'; if (!extension_loaded($module)) { dl($module . '.' . PHP_SHLIB_SUFFIX); } $functions = get_extension_funcs($module); echo "Functions available in the test extension:" . $br; foreach ($functions as $func) { echo $func . $br; } echo $br; // testing forp functions echo '- Enable' . $br; forp_start(); /** * @ProfileGroup("fibo") * @ProfileCaption("fibo of #1") */ function fibo($x) { if ($x <= 1) { return $x; } else { return fibo($x - 1) + fibo($x - 2); } } for ($i = 1; $i < 10; $i++) { printf('fibo(%1$s) = %2$s' . $br, $i, fibo($i)); }
<?php // Starting forp ($forpIsLoaded = extension_loaded("forp")) && define('FORP_UI_SRC', '../../../src/built/forp.min.js') && forp_start(); if (strpos($_SERVER['HTTP_ACCEPT'], 'json')) { var_dump("XHR result"); } else { ?> <html> <head> <script type="text/javascript"> <!-- function ajax(callback) { var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) { callback(xhr.responseText); } }; xhr.open("GET", "index.php", true); xhr.setRequestHeader('X-Requested-With', 'xmlhttprequest'); xhr.setRequestHeader("Accept","application/json"); xhr.send(null); } function xhrCallback(data) { document.getElementById("output").innerHTML = data; } //--> </script> </head>