Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

279
Views
URI de validación de PHP

Quiero validar un URI (no solo una URL) en PHP, aunque no pude encontrar ninguna forma de hacerlo.

PHP tiene parse_url() pero no es para URI , sería útil encontrar una forma adecuada de validar estructuras de URI como las siguientes:

 content://com.example.provider/articles/?optional=queries
over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Para validar URI, puede usar el filtro FILTER_VALIDATE_URL con la función filter_var() en PHP.

 $uri = "content://com.example.provider/articles/?optional=queries" if (filter_var($uri, FILTER_VALIDATE_URL)) { // Valid URI, do something here. }
over 4 years ago · Santiago Trujillo Report

0

Puedes probar el siguiente código:

 $url = "http://www.google.com"; if (!filter_var($url, FILTER_VALIDATE_URL) === false) { echo("$url is a valid URL"); } else { echo("$url is not a valid URL"); }
over 4 years ago · Santiago Trujillo Report

0

Necesita filtrar también para eliminar caracteres ilegales.

 $url = "http://www.google.com"; // Remove all illegal characters from a url $url = filter_var($url, FILTER_SANITIZE_URL); // Validate url if (filter_var($url, FILTER_VALIDATE_URL)) { echo("$url is a valid URL"); } else { echo("$url is not a valid URL"); }

Aquí, se requiere que la URL tenga una cadena de consulta para que sea válida:

$url = "https://www.w3schools.com";

 if (filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_QUERY_REQUIRED)) { echo("$url is a valid URL"); } else { echo("$url is not a valid URL"); }
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!