I’m making a PHP script where I use a class boolean variable, but for some reason, when I want to set it to true, it doesn’t work :/
<?php
class TinyFram {
private $urlMatched;
public function get($url, $method){
$urlR = str_replace('/', '\/', $url);
$urlR = '^' . $urlR . '\/?$';
if (preg_match("/$urlR/i", $reqURI, $rMatch)) {
$this->urlMatched = true; // I SET IT TO TRUE HERE
$method($rMatch);
}
if(!$this->urlMatched) {
echo var_dump($this->urlMatched); // BUT HERE IT SHOWS AS FALSE
notFound($rMatch);
}
}
}
?>
What I’m doing wrong? thanks!
Your preg_match is not matching, so the variable never gets set to true.