Posted
on December 8, 2015, 7:21 am,
by admin,
under
php.
Dont use count()
in loops because each iteration will count the number of elements; make a variable $count = count($array)
and use the variable instead
Posted
on December 7, 2015, 9:49 am,
by admin,
under
php.
class Newclass
{
public static function compare($a, $b)
{
return strcmp($a["name"], $b["name"]);
}
}
usort($array_to_srt, array("Newclass", "compare"));
uasort($array_to_srt, array("Newclass", "compare"));
The difference between usort and uasort is that uasort keeps the keys, usort resets them and enumerate from scratch. |
Posted
on December 1, 2015, 5:28 am,
by admin,
under
git.
git reset --hard origin/master |
Posted
on November 29, 2015, 3:49 pm,
by admin,
under
git.
git push -f origin myremotebranch
git push -f myprivate master:master
git push -f |
Posted
on November 25, 2015, 5:48 am,
by admin,
under
linux.
tail -n +1 filename.txt > filename.txt.new |
Posted
on November 24, 2015, 6:52 am,
by admin,
under
git.
git reset --hard origin/master |
Posted
on November 17, 2015, 5:06 pm,
by admin,
under
git.
export GIT_SSL_NO_VERIFY=1 |
Posted
on November 17, 2015, 12:06 pm,
by admin,
under
laravel.
<?php
dd(\DB::getQueryLog()); |
Posted
on November 17, 2015, 12:05 pm,
by admin,
under
php.
<?php
error_reporting(-1);
ini_set('display_errors', 'On'); |
Posted
on November 16, 2015, 5:58 am,
by admin,
under
php,
tips.
1. Objects should be passed by reference always, arrays and scalars are passed by value.
2. If you are working on a very large array and plan on modifying it inside a function, you actually should use a reference to prevent it from getting copied, which can seriously decrease performance or even exhaust your memory limit.
3. If it is avoidable though (that is small arrays or scalar values), I’d always use functional-style approach with no side-effects, because as soon as you pass something by reference, you can never be sure what passed variable may hold after the function call, which sometimes can lead to nasty and hard-to-find bugs.
4. Scalar values should never be passed by reference, because the performance impact can not be that big as to justify the loss of transparency in your code.