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 | |
$memcache = new Memcache; | |
$memcache->connect('localhost', 11211) or die ("Could not connect"); | |
$version = $memcache->getVersion(); | |
echo "Server's version: ".$version."<br/>\n"; | |
$tmp_object = new stdClass; | |
$tmp_object->str_attr = 'test'; |
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 | |
include 'simple_html_dom.php'; | |
$cookie_jar = tempnam('/tmp', 'cookie'); | |
$c = curl_init('http://www.bmkg.go.id/BMKG_Pusat/Meteorologi/Prakiraan_Cuaca_Indonesia.bmkg'); | |
curl_setopt($c, CURLOPT_FOLLOWLOCATION, true); | |
curl_setopt($c, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($c, CURLOPT_COOKIEFILE, $cookie_jar); | |
$page = curl_exec($c); |
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 | |
abstract class Ayam{ | |
public abstract function berjenisKelamin(); | |
} | |
class AyamJantan extends Ayam{ | |
public function berjenisKelamin(){ | |
echo "jantan"; | |
} | |
} |
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($quote = apc_fetch('starwars')){ | |
echo $quote; | |
echo ' [cached]'; | |
}else{ | |
$quote = 'Do, or do not. There is no try. -- Yoda, Star Wars'; | |
echo $quote; | |
apc_add('starwars', $quote, 120); | |
} | |
/* |
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 | |
$items = array(100, 100, 20, 20, 30, 45, 45, 50); | |
echo "<pre>"; | |
print_r(array_keys(array_count_values($items), 1)); | |
echo "</pre>"; | |
?> |
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 | |
$data1 = array(1,2,3); | |
$data2 = array(1,2,3,4,5,6,7,8,9,10); | |
$diff = array_diff($data2, $data1); | |
echo "<pre>"; | |
print_r($diff); | |
echo "</pre>"; | |
?> |
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 | |
$array = array( | |
array(2,3,4,5,6,7,8), | |
array(9,10,11,12,13,14,15), | |
); | |
echo "<pre>"; | |
print_r($array); | |
echo "</pre>"; |
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 | |
$arr = array( | |
array(1,2), | |
array(1,3), | |
array(1), | |
array(2), | |
); | |
foreach($arr as $x => $y){ | |
echo implode(",", $y)."<br />"; |
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 | |
for ($i=1;$i<=4;$i++){ | |
echo "$i"."<BR>"; | |
$_i[] = $i; | |
} | |
echo "-------------------------------------------------------------<br/>"; | |
for ($a=4;$a<=6;$a++){ | |
echo "$a"."<BR>"; |
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 | |
#testing array map to combine different length arrays | |
$data1 = array(1,2,3,4,5); | |
$data2 = array('satu', 'dua', 'tiga', 'empat'); | |
$map = array_map(null, $data1, $data2); | |
echo "<pre>"; | |
print_r($map); |
OlderNewer