3v4l.org

run code in 300+ PHP versions simultaneously
<?php $db_mock = array( 'token' => 'jfdfdkfldkhvmxhfuf', 'scope' => 'User.Profile' ); class API { private static $Token; public static function setToken($token) { self::$Token = $token; } public static function getToken() { return self::$Token; } } class Endpoint { public function __construct() { if(empty(API::getToken())) { throw new Exception('Invalid or undefined token.'); } } public function isToken($db_mock) { // replace with database logic if(in_array(API::getToken(), $db_mock)) { // run the logic for returning response for scope return true; } else { return false; } } } API::setToken('jfdfdkfldkhvmxhfuf'); $e = new Endpoint(); echo (int)$e->isToken($db_mock);
Output for git.master, git.master_jit, rfc.property-hooks
1

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
126.96 ms | 405 KiB | 5 Q