Rápli András
Rápli András

Reputation: 3923

Custom routing PHP

I'm trying out some custom php routing, and something is wrong at the last line of this function:

public function is_valid_uri($a){
 $s=$_SERVER["REQUEST_URI"];
 return (preg_match('/'.$a.'/i',$s))?true:false;
}

I'm testing it using:

die($route->is_valid_uri("\/u\/u\/?[0-9]*"));

What's the problem? If the uri is incorrect, it should return false. It returns nothing at all, just dies.

Upvotes: 0

Views: 134

Answers (1)

laurent
laurent

Reputation: 90776

Try this instead:

var_dump($route->is_valid_uri("\/u\/u\/?[0-9]*"));
die();

If you just print a boolean and it's "false", PHP will print an empty string instead.

Upvotes: 1

Related Questions