lastguest / mu Goto Github PK
View Code? Open in Web Editor NEWA tweet-sized PHP micro-router
A tweet-sized PHP micro-router
class µ{function __callStatic($n,$a){static $r;return $n=='_'?@$r[getenv('REQUEST_METHOD')][getenv('REDIRECT_URL')]():$r[$n][$a[0]]=$a[1];}}
Still only 140 characters but now it won't throw errors on missing options and it won't complain about constants (REQUEST_METHOD
) that are not defined.
Also, I would default to using REQUEST_URI
since Nginx/Apache both use that.
Eg
' ; }); µ::GET('/', function() { echo $_GET['username']; }); ?>It is impossible to get a username.
What's wrong? Help me please.
used the commented code with PHP7.1:
Fatal error: Uncaught Error: Function name must be a string in /mu/mu.php:19 Stack trace: #0 /mu/index.php(49): µ::__callStatic('_', Array) #1 {main} thrown in /mu/mu.php on line 19
19: @$callbackMapgetenv(REQUEST_METHOD).getenv(REQUEST_URI);
Current version (138 characters):
class µ{static function __callStatic($n,$a){static$r;return$n=='_'?@$r[getenv(REQUEST_METHOD).getenv(REQUEST_URI)]():$r[$n.$a[0]]=$a[1];}}
Applying the changes (130 characters):
class µ{static function __callStatic($n,$a){static$r;$n[1]?$r[$n.$a[0]]=$a[1]:@$r[getenv(REQUEST_METHOD).getenv(REQUEST_URI)]();}}
Hardcore version (117 characters):
class µ{function __call($n,$a){static$r;$n[1]?$r[$n.$a[0]]=$a[1]:@$r[getenv(REQUEST_METHOD).getenv(REQUEST_URI)]();}}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.