Name
Show git branch in Php php
public function git_branch()
{
$branch = NULL;
$file = dirname(__FILE__) . "/../.git/HEAD";
if(@file_exists($file)) {
$fd = file($file, FILE_USE_INCLUDE_PATH);
$tmp = explode("/", $fd[0]);
$branch = trim($tmp[2]);
}
return $branch;
}
echo git_branch();
Last update: 496 days ago