• 0

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191


File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

How to check if a URL contains a query string in PHP

There seem to be multiple solutions to check if a URL contains a specific key or value,

but strangely I can't find a solution for determining if URL does or does not have a query at all.

Using PHP, I simply want to check to see if the current URL has a query string.

For example http://xyz.com/abc/?key=value VS http://xyz.com/abc/

For any URL as a string:

if (parse_url($url, PHP_URL_QUERY)) {
    echo 'has query string';
} else {
    echo 'no query string';

If it's for the URL of the current request, simply:

if ($_GET)
  • 0
Reply Report