Latte\Helpers::startsWith PHP Method

startsWith() public static method

Starts the $haystack string with the prefix $needle?
public static startsWith ( $haystack, $needle ) : boolean
return boolean
    public static function startsWith($haystack, $needle)
    {
        return strncmp($haystack, $needle, strlen($needle)) === 0;
    }

Usage Example

Beispiel #1
0
 /**
  * Returns template source code.
  * @return string
  */
 public function getContent($file)
 {
     $file = $this->baseDir . $file;
     if ($this->baseDir && !Latte\Helpers::startsWith($this->normalizePath($file), $this->baseDir)) {
         throw new \RuntimeException("Template '{$file}' is not within the allowed path '{$this->baseDir}'.");
     } elseif (!is_file($file)) {
         throw new \RuntimeException("Missing template file '{$file}'.");
     } elseif ($this->isExpired($file, time())) {
         if (@touch($file) === FALSE) {
             trigger_error("File's modification time is in the future. Cannot update it: " . error_get_last()['message'], E_USER_WARNING);
         }
     }
     return file_get_contents($file);
 }
All Usage Examples Of Latte\Helpers::startsWith