'ello all.

I am trying to pull variables from a URL.

My URL can look like:

website.com
website.com/
website.com/index.php
website.com/index.php/
website.com/index.php/1
website.com/index.php/1/2
website.com/index.php/1/2/abc
etc...

Here is my current code to get the 1/2/abc part.

My question is ... is this the most efficient way? Can someone spoof PHP_SELF?

$VARS = preg_replace('#^([\/]?[-_A-Za-z0-9]*(\.php)?[\/]?(.*))$#', '\\3', $_SERVER['PHP_SELF']);
	echo $VARS;

TIA!

    playing around with phpinfo(), it seems that $_SERVER['PATH_INFO'] will return anything after the .php it also might depend on what you have the argument separator set to in php.ini.

      $VARS = ($pos = strpos($_SERVER['PHP_SELF'], '.php/')) ? 
              explode('/', substr($_SERVER['PHP_SELF'], $pos + 5)) : array();
      
        NogDog wrote:
        $VARS = ($pos = strpos($_SERVER['PHP_SELF'], '.php/')) ? 
                explode('/', substr($_SERVER['PHP_SELF'], $pos + 5)) : array();
        

        :eek:

        edit

        After looking at it for a second, it's not that complicated.

          Write a Reply...