This code may be what you are looking for: Use: phpfile.php/en/11 Note: mod_rewrite is not required.
<?php $DEFAULT_ACTION = 'badAction'; $pathInfo = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : ''; $pathParts = explode('/', substr($pathInfo, 1)); $action = isset($pathParts[0]) ? $pathParts[0] : $DEFAULT_ACTION; if (function_exists($action)) { $action($pathParts); } else { badAction(); } function badAction($parts = null) { print 'The function specified is invalid.'; } function en($parts) { $name = isset($parts[1]) ? $parts[1] : 'undefined'; $xml = new SimpleXMLElement('<message>Number: ' . $name . ' </message>'); header('Content_Type: text/xml'); print $xml->asXML(); } ?>
ps. I found the code in "Professional PHP6" ISBN: 978-0-470-39509-7
source share