This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$in_array=array("foo"=>"fooval","baz"=>"bazval"); | |
$in_array+=array_fill_keys(array("foo","bar","baz"),false); | |
// array_fill_keys is since PHP 5.2.0 | |
// useage: | |
echo $in_array["foo"]?:"foodef"; | |
// short ternary operator is since PHP 5.3.0 | |
echo "\n"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function bxt_fileList($d,$x=false){ | |
foreach(scandir($d) as $f)if(is_file($d.'/'.$f)&&(!$x||preg_match('/'.$x.'$/i',$f)))$l[]=$f; | |
return $l; | |
} | |
// silly "ninja" comment code from | |
// http://de3.php.net/manual/en/function.scandir.php#90628 | |
function file_list($d,$x){ | |
foreach(array_diff(scandir($d),array('.','..')) as $f)if(is_file($d.'/'.$f)&&(($x)?ereg($x.'$',$f):1))$l[]=$f; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
echo foo()[0]; // PHP Parse error: syntax error, unexpected '[', expecting ',' or ';' | |
function foo() { | |
return array("cant thouch this"); | |
} | |
// use this instead: | |
list($tmp)= foo(); | |
echo $tmp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// echo (new Foo())->$bar; // fails | |
// PHP Parse error: syntax error, unexpected T_OBJECT_OPERATOR, expecting ',' or ';' | |
echo Foo::getI()->bar; //works | |
class Foo { | |
public function __construct() { | |
$this->bar="hello world\n"; | |
} | |
static function getI() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
svn diff | kompare -o - | |
#and of course: | |
git diff | kompare -o - |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if(rand(1,1000)==42) {trigger_error($debugout);} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php $var="foo"; $foo=array(); ${true?$var:"bar"}[]=$var; var_dump($foo); | |
/* Output: | |
array(1) { | |
[0]=> | |
string(3) "foo" | |
} | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php echo 0 || 1337 ? 4 : 0 | -4 ? 5 : 0 ? 7 ^ 5: 0 ; // 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({abc:1,def:1,jkl:1}[xyz]) | |
// nearly the same as: | |
( xyz=="abc" || xyz=="def" || xyz=="jkl" ) | |
// and.... | |
(function(){switch(pn) { | |
case "prv":return "previous"; | |
case "nxt":return "next"; | |
}})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(while true; do echo -n $'\a';sleep 1; done;) & |
OlderNewer