Exemple #1
0
 /**
  * get the 'q'
  * @return Ambigous <The, unknown, string>
  */
 public static function q()
 {
     return simphp_request_path();
 }
Exemple #2
0
/**
 * Return a component of the current SimPHP path.
 *
 * When viewing a page at the path "admin/content/types", for example, arg(0)
 * would return "admin", arg(1) would return "content", and arg(2) would return
 * "types".
 *
 * Avoid use of this function where possible, as resulting code is hard to read.
 * Instead, attempt to use named arguments in menu callback functions. See the
 * explanation in menu.inc for how to construct callbacks that take arguments.
 *
 * @param $index
 *   The index of the component, where each component is separated by a '/'
 *   (forward-slash), and where the first component has an index of 0 (zero).
 *
 * @return
 *   The component specified by $index, or NULL if the specified component was
 *   not found.
 */
function arg($index = NULL, $path = NULL)
{
    static $arguments;
    if (!isset($path)) {
        $path = simphp_request_path();
    }
    if (!isset($arguments[$path])) {
        $arguments[$path] = explode('/', $path);
    }
    if (!isset($index)) {
        return $arguments[$path];
    }
    if (isset($arguments[$path][$index])) {
        return $arguments[$path][$index];
    }
}