Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created August 20, 2019 23:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/6a27089bc970007f337d8f4dddabd6d7 to your computer and use it in GitHub Desktop.
Save parzibyte/6a27089bc970007f337d8f4dddabd6d7 to your computer and use it in GitHub Desktop.
<?php
/*
Cortar cadenas en PHP
@author parzibyte
https://parzibyte.me/blog
*/
$uri = "http://localhost/plantilla-php/usuarios?token=asdfg123";
echo "uri antes: $uri";
$posicionSignoDeInterrogacion = strpos($uri, "?");
if ($posicionSignoDeInterrogacion !== false) {
$uri = substr($uri, 0, $posicionSignoDeInterrogacion);
}
echo "\n\nuri después: $uri";
/*
Salida:
uri antes: http://localhost/plantilla-php/usuarios?token=asdfg123
uri después: http://localhost/plantilla-php/usuarios
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment