Comment puis-je obtenir l'URL complète, comme http://www.domain.com/page.php?id=someid&page=1
, et pas seulement http://www.domain.com/page.php
?Comment puis-je obtenir l'URL complète en PHP?
0
A
Répondre
4
$_SERVER['QUERY_STRING']
a la partie chaîne de requête du URL.
3
Une réponse rapide:
$url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
1
$url = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'].$_SERVER['QUERY_STRING'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'].$_SERVER['QUERY_STRING'];
+0
'REQUEST_URI' est déjà associé à' QUERY_STRING'. – brianreavis
Questions connexes
- 1. Comment puis-je obtenir la chaîne complète de PHP getTraceAsString()?
- 2. comment obtenir descendant complète hiearchy?
- 3. mod_rewrite - PHP: $ _GET pas complète
- 4. Demande HTTP complète de cURL en PHP
- 5. Obtenir l'URL de la page complète avec PHP
- 6. Comment obtenir l'URL complète actuelle (URL + fragments) de la page Web en php. .
- 7. Obtenir l'URL complète avec PHP et inclure sous-domaine
- 8. obtenir requête complète sql Jython
- 9. Comment obtenir la saisie complète dans un flux RSS 2.0
- 10. Attraper l'action complète en utilisant
- 11. Obtenir la chaîne de requête complète SolrQuery
- 12. comment puis-je obtenir l'adresse complète du bureau de l'utilisateur?
- 13. Comment puis-je obtenir une version complète de TortoiseHg
- 14. Comment obtenir l'adresse URL complète d'une page Drupal?
- 15. comment puis-je obtenir l'URL complète de GetWebResourceUrl
- 16. php extraire l'url complète avec les variables
- 17. Auto complète en VC++
- 18. Comment obtenir une déclaration C# complète pour un type?
- 19. Comment obtenir un post SOAP en PHP?
- 20. Comment obtenir A-B en PHP?
- 21. Comment obtenir une requête brute en PHP?
- 22. Comment puis-je obtenir l'appelé en PHP?
- 23. Comment obtenir une URL en PHP
- 24. Rétroaction complète d'AJAX
- 25. Conversion NSString en monnaie - L'histoire complète
- 26. obtenir json en utilisant php
- 27. Comment convertir une URL relative en URL complète?
- 28. Comment obtenir une pile complète à partir d'un exe/dll en mode mixte écrasé?
- 29. Comment obtenir la commande complète "java -cp xxxx com.xxx.class" émise en interne par eclipse?
- 30. La journalisation des erreurs PHP n'est pas complète?
si PHP_SELF + QUERY_STRING devrait le faire? – kmunky
IIRC, '$ PHP_SELF' n'inclut pas le nom d'hôte - vous voudriez ajouter' $ _SERVER ['SERVER_NAME'] 'pour cela. – Amber
Pourquoi n'utilisez-vous pas simplement '$ _SERVER ['REQUEST_URI']', comme Zied l'a suggéré? – brianreavis