Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
function rec($el)
{
process($el);
foreach($el->childs as $child)
rec($child);
}
function non_rec($root)
{
$stack = new Stack();
$stack->push($root);
while(!$stack->empty())
{
$el = $stack->pop();
process($el);
foreach ($el->childs as $child)
$stack->push($child);
}
}
function getAllFiles( $dir_start ){
$dirs = $files = array();
$dirs[] = $dir_start;
while (sizeof($dirs)>0) {
$k=array_keys($dirs);
$dir = new DirectoryIterator( $dirs[$k[0]] );
foreach( $dir as $f ) {
$fn = $f->getFilename();
if (!in_array($fn, array('.','..'))) {
if (is_dir($fn)) $dirs[] = $dir_start.'/'.$fn;
else $files[] = $fn;
}
}
unset($dirs[$k[0]]);
}
return $files;
}
$files = getAllFiles("C:/");
function getFilelist( $dir0 ) {
$f = $d = array();
$d[] = $dir0;
while (sizeof($d)>0) {
$l = glob( array_shift($d).'*' );
foreach( $l as $n ) is_dir($n) ? $d[]=$n.'/' : $f[]=$n;
}
return $f;
}
Шаблонизатор шаблонизирует шаблон
Объект | свойство | значение
-------+----------+-------------
Сыночек| Родитель | Папочка
Дочка | Родитель | Папочка
Папочка| Родитель | Дедушка
Q: Why was “\” chosen given that it makes it impossible to write something like “spl_autoload_register(array(“myNamespace\theLoader”, “load”));” because the \t would be interpreted as a tab?
A: It is already impossible to write Windows paths in PHP in the same way, ergo at least half the PHP community is already familiar with the idea that they need to either use single quotation marks or escape the backslash (“\\”).
Изменения в языке зачастую становятся известны за месяцы, а то и годы до их реализации.Так должно быть. А как на практике? А вот как:
А вы пишите код не на хаках — все работать и будет замечательно.Перевод с русского на русский: язык — дерьмо, но и на нём можно сделать неплохую вещь. Да, можно, но зачем?
таких примеров масса. Следуйте рекомендациям «хорошего» кода и 90% проблем изчезнет.Знаете — это напоминает примерно следующую рекламу:
Руби — всю моторику придется перекручивать. А спорить со спинным мозгом — сложно
Есть где-то статья perl vs Python почитай, там показано что у перла ниодного преимущества.
В защиту PHP
Насчет передачи по ссылке, это может быть актуальным, когда идет передача в функцию переменной(строки, объекта, etc) большого размера и важно поддерживать небольшой расход памяти при этом.
Warning: call-time pass-by-reference has been deprecated…
$x = (bool) "false"; //возвратит true $x = (bool) "0"; //возвратит false
When converting to boolean, the following values are considered FALSE:
the boolean FALSE itself
the integer 0 (zero)
the float 0.0 (zero)
the empty string, and the string «0»
an array with zero elements
an object with zero member variables (PHP 4 only)
the special type NULL (including unset variables)
SimpleXML objects created from empty tags
Every other value is considered TRUE (including any resource).
В защиту PHP