Understanding $_SERVER['PHP_SELF'], $PHP_SELF, $_SERVER['REQUEST_URI'] and $_SERVER['SCRIPT_NAME'] in PHP and when to use what Entendimiento $ _SERVER [ 'PHP_SELF'], $ PHP_SELF, $ _SERVER [ 'REQUEST_URI'] y $ _SERVER [ 'SCRIPT_NAME'] en PHP y cuándo utilizar qué
The above PHP variables have slight differences which are often ignored, often leading to problems in large scale deployments or product solutions. Las anteriores variables han PHP pequeñas diferencias que a menudo son ignoradas, que a menudo provoca problemas en los despliegues a gran escala de productos o soluciones. I have attempted to debug them for you. He tratado de depurar por usted.
$_SERVER['SCRIPT_NAME'] $ _SERVER [ 'SCRIPT_NAME']
This contains the current script’s path. Este contiene la secuencia de comandos del actual camino. If you access Si accede http://blog.taragana.com/ or o http://blog.taragana.com/index.php the $_SERVER['SCRIPT_NAME'] will be same - /index.php . los $ _SERVER [ 'SCRIPT_NAME'] va a ser el mismo - / index.php. It is irrespective of the actual URI ($_SERVER['REQUEST_URI']) used to access the site. Es independientemente de la URI real ($ _SERVER [ 'REQUEST_URI']) utilizados para acceder al sitio.
As it returns the actual script name, it fails provide additional path information that may be present. Como se devuelve el nombre real de script, no proporcionar información adicional sobre la ruta que pueden estar presentes. So if the $_SERVER['REQUEST_URI'] is /index.php/big/directory/ then too the $_SERVER['SCRIPT_NAME'] will be same - /index.php . Por lo tanto, si los $ _SERVER [ 'REQUEST_URI'] es / index.php / big / directorio / entonces también los $ _SERVER [ 'SCRIPT_NAME'] va a ser el mismo - / index.php.
$_SERVER['SCRIPT_NAME'] is supported on all platforms $ _SERVER [ 'SCRIPT_NAME'] se apoya en todas las plataformas
$_SERVER['PHP_SELF'] $ _SERVER [ 'PHP_SELF']
This is the filename of the currently executing script, relative to the document root. Este es el nombre del fichero actualmente la ejecución de secuencias de comandos, relativo al documento raíz. However, unlike $_SERVER['SCRIPT_NAME'], it provides additional path information like $_SERVER['REQUEST_URI'] when the actual php file is present in the path. Sin embargo, a diferencia de $ _SERVER [ 'SCRIPT_NAME'], que proporciona información adicional sobre la ruta como $ _SERVER [ 'REQUEST_URI'] cuando el archivo php está presente en el camino. So when the $_SERVER['REQUEST_URI'] is /index.php/big/directory/ then $_SERVER['PHP_SELF'] will be /index.php/big/directory/ . Así que cuando el $ _SERVER [ 'REQUEST_URI'] es / index.php / big / directorio / entonces $ _SERVER [ 'PHP_SELF'] será / index.php / big / directory /.
However if all the URI’s under http://www.example.com/ is mapped to http://www.example.com/index.php, then, for example, http://www.example.com/abc/def will return /index.php like $_SERVER['SCRIPT_NAME']. Sin embargo, si todas las URI en virtud del http://www.example.com/ está asignada a http://www.example.com/index.php, entonces, por ejemplo, http://www.example.com/ abc / def volverá / index.php como $ _SERVER [ 'SCRIPT_NAME']. Note that $_SERVER['REQUEST_URI'] data is ignored for this request. Tenga en cuenta que $ _SERVER [ 'REQUEST_URI'] se pasa por alto los datos de esta solicitud.
$_SERVER['PHP_SELF'] is supported on all platforms. $ _SERVER [ 'PHP_SELF'] se apoya en todas las plataformas.
Pages: 1 Páginas: 1 2
Filed under Filed under Headline News Headline News , How To Cómo , PHP , Web , Web Hosting Web Hosting , Web Services Web Services | |
| |
RSS 2.0 RSS 2,0 | |
Email this Article Enviar artículo
You may also like to read También puede leer |





June 15th, 2006 at 3:45 pm 15 de junio de 2006, a las 3:45 pm
$_SERVER variables not set by Tomcat $ _SERVER Variables no establecidas por Tomcat
Not able to get the value for variable in Tomcat 5.5 and PHP Version 5.1.4 configuration No es capaz de tener el valor de la variable en 5,5 Tomcat y PHP versión 5.1.4 de configuración
In fact, only values in _SERVER are De hecho, sólo los valores están en _SERVER
_SERVER is array 3 _SERVER Es array 3
Key: REQUEST_TIME value: 1150399842 Clave: REQUEST_TIME valor: 1150399842
Key: argv value: Array Clave: valor argv: Array
Key: argc value: 0 Clave: argc valor: 0
Searched but couldn’t find anything relevant. Busqué pero no pudo encontrar nada relevante. Any pointers? Cualquier punteros?
August 17th, 2006 at 12:08 am 17 de agosto de 2006, a las 12:08 am
Hey…I was wondering how to call a particular function by using the $_SERVER['PHP_SELF'] command. Hey… Me preguntaba cómo llamar a una función en particular mediante el uso de los $ _SERVER [ 'PHP_SELF'] comando. Is there any supported way of calling a function from this? ¿Hay alguna forma de apoyo a llamar a un función de esto?
-Dan P. P.-Dan
December 3rd, 2006 at 4:40 am 3 de diciembre de 2006, a las 4:40 am
hey, ¡eh!,
I have a problem in which the url isn’t parsed properly so it doesnt add the .php to the end of the address in the url bar. Tengo un problema en el que la URL no es debidamente analizada por lo que añadir la doesnt. Php al final de la dirección url en la barra. for example, por ejemplo, http://www.mysite.com/test/11 is suppose to be se supone que debe ser http://www.mysite.com/test/11.php the .php is missing. la. php está disponible.
My code: Mi código:
Options +FollowSymlinks Opciones + FollowSymLinks
RewriteEngine On El Reescribirmotor
RewriteBase / RewriteBase /
AddType text/xml .xslt AddType text / xml. XSLT
SetHandler text/xml SetHandler text / xml
# PHP is in CGI Mode, so we need a different mod_rewrite # PHP es en modo CGI, así que necesitamos otra mod_rewrite
RewriteCond %{REQUEST_URI} !categories\.php RewriteCond% (REQUEST_URI)! Categorías \. Php
RewriteRule ^categories(.*) /categories.php?$1 [L] RewriteRule ^ categorías (.*) / categories.php? $ 1 [L]
RewriteCond %{REQUEST_URI} !questions\.php RewriteCond% (REQUEST_URI)! Preguntas \. Php
RewriteRule ^questions(.*)$ /questions.php?$1 [L] RewriteRule ^ preguntas (.*)$ / questions.php? $ 1 [L]
RewriteCond %{REQUEST_URI} !search\.php RewriteCond% (REQUEST_URI)! Búsqueda \. Php
RewriteRule ^search(.*)$ /search.php?$1 [L] RewriteRule ^ búsqueda (.*)$ / search.php? $ 1 [L]
December 20th, 2006 at 12:55 pm Diciembre 20, 2006 a las 12:55 pm
Hi there, Hola,
I need to retrieve just the page name from the URL - anyone knows how could I do it? Tengo que recuperar sólo el nombre de la página de la URL - nadie sabe cómo podría hacerlo?
I want then assing its value to a variable and use it in sql query for comparasion. Quiero entonces assing su valor a una variable y lo utilizan en la consulta SQL para la comparación.
Any help would be appreciated. Cualquier ayuda sería apreciada.
I look forward. Espero con interés.
Sebastian
May 2nd, 2007 at 11:33 pm 2 de mayo de 2007, a las 11:33 pm
how can i get the file name without the directory name ¿Cómo puedo obtener el nombre del archivo sin el nombre de directorio
June 19th, 2007 at 8:05 am Junio 19, 2007 a las 8:05 am
subash have searching ajob subash han buscando ajob
August 7th, 2007 at 6:42 am 7 de Agosto, 2007 a las 6:42 am
Is this better to call php_self function or create a new file.Because when people refresh it submit the message twice, how can overcome this issue. ¿Es esto mejor llamar a las php_self función o crear una nueva file.Because cuando la gente de refresco que le presente el mensaje dos veces, ¿cómo se puede superar este problema.
October 8th, 2007 at 6:22 am Octubre 8, 2007 a las 6:22 am
Hello.. Hola ..
I’ve done with a program which send copy from local machine to server. Que he hecho con un programa que envíe copia de máquina local con el servidor.
I m having problem while copying the file. Soy haber problema al copiar el archivo. Its copied, but goes in Apache server. Su copiados, pero va en servidor Apache. Please help me to copy that file in server(www)folder. Por favor, ayúdame a copiar ese fichero en el servidor (www) carpeta.
November 1st, 2007 at 1:24 am 1 de noviembre de 2007, a las 1:24 am
Very useful … did clarify some technicalities for me. Muy útil… sí aclarar algunos detalles técnicos para mí. Thanks for the headsup! Gracias por el headsup! =)
February 17th, 2008 at 7:00 am 17 de febrero de 2008, a las 7:00 am
While I am excecuting $_SERVER['PHP_SELF']then I am getting one message in my browser Forbidden Si bien estoy de ejecución $ _SERVER [ 'PHP_SELF'] entonces yo estoy recibiendo un mensaje en mi navegador Prohibida
You don’t have permission to access / Usted no tiene permiso para acceder a /
March 10th, 2008 at 10:02 am 10 de Marzo de 2008 a 10:02 am
thankyou for the informative article. gracias por el artículo informativo.
June 10th, 2008 at 8:25 am 10 de junio de 2008 a 8:25 am
Hi the inforamtin on this site is really helpfull Hola el inforamtin en este sitio es realmente útil
Thanks Gracias
! ! BYE BYE