本文整理匯總了PHP中Program::updateLabels方法的典型用法代碼示例。如果您正苦於以下問題:PHP Program::updateLabels方法的具體用法?PHP Program::updateLabels怎麽用?PHP Program::updateLabels使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Program
的用法示例。
在下文中一共展示了Program::updateLabels方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: readProgram
/**
* @return Program
*/
public static function readProgram($fileName)
{
// BufferedReader b;
try {
$b = fopen($fileName, 'r');
$p = new Program();
// Statement s;
// String str;
do {
$str = fgets($b);
if ($str != null) {
//int j;
$str = trim($str);
if (strlen($str) == 0) {
continue;
}
if (in_array($str[0], array(';', '#', '%'))) {
continue;
}
$mark = "";
$j = strpos($str, ":");
if ($j > 0) {
$mark = trim(substr($str, 0, $j));
$str = trim(substr($str, $j + 1));
}
$fonction = "";
$j = strpos($str, " ");
if ($j > 0) {
$fonction = trim(substr($str, 0, $j));
$str = trim(substr($str, $j + 1));
// We extract the string after the function
$args = str_getcsv($str, " ", "'");
switch (count($args)) {
case 1:
$s = new Statement($mark, $fonction, $args[0]);
break;
case 2:
$s = new Statement($mark, $fonction, $args[0], $args[1]);
break;
case 3:
$s = new Statement($mark, $fonction, $args[0], $args[1], $args[2]);
break;
case 4:
$s = new Statement($mark, $fonction, $args[0], $args[1], $args[2] . ' ' . $args[3]);
break;
}
} else {
$s = new Statement($mark, $str, "");
}
$p->addStatement($s);
}
} while ($str !== false);
fclose($b);
$p->updateLabels();
return $p;
} catch (\Exception $io) {
return null;
}
}