3v4l.org

run code in 300+ PHP versions simultaneously
<?php // adiputra. Sabtu, 20 April 2013. function CariKata($s, $keyword1, $keyword2) { $l1=strlen($keyword1); $x1=strpos($s, $keyword1); $x2=strpos($s, $keyword2, $x1+$l1); $l=$x2-($x1+$l1); return substr($s, $x1+$l1, $l); } if( !function_exists("curl_init") ) { die("curl nya blom di aktifin ato di install"); } else { // mengambil data awal tiki online, gunanya untuk mengambil cookie di header page si TIKI $url_1 = "http://www.tiki-online.com/"; $c = curl_init(); curl_setopt($c, CURLOPT_AUTOREFERER, 1); curl_setopt($c, CURLOPT_HTTPGET, 1); curl_setopt($c, CURLINFO_HEADER_OUT,1); curl_setopt($c, CURLOPT_VERBOSE, 1); curl_setopt($c, CURLOPT_HEADER, 1); curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); curl_setopt($c, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($c, CURLOPT_URL, $url_1); $hasil_1 = curl_exec($c); curl_close($c); // echo $hasil_1; // proses ngambil cookie si tiki dari hasil curl hasil_1; $cookie = CariKata($hasil_1,'PHPSESSID=',';'); // echo $cookie; // data yg dipost tiki, kenapa empat data ? // dan dari mana kita tahu kalau si TIKI ada 4 variable. Cek di firebug, buat tab NETnya $postdata = array( "get_des" => "BEKASI", "get_ori" => "BANDUNG", "get_wg" => 1, "submit" => "Check" ); // get_des, get_ori ini masih hardcode, belum ada pengecekan kota yang tersedia di TIKI, jadi seharusnya ada proses pengecekan kota sih. $url_2 = "http://www.tiki-online.com/?cat=KgfdshfF7788KHfskF"; // url ini selalu statik, tapi mungkin berubah, jadi mesti dihandel. // curl untuk cek harga tiki. $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_URL, $url_2); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_COOKIE, "PHPSESSID=$cookie;"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); $hasil_2 = curl_exec($ch); curl_close($ch); echo $hasil_2; // tinggal pecah2 data dari hasil_2 html untuk mengambil harga. }
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.6 - 7.2.33, 7.3.12 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
curl nya blom di aktifin ato di install

preferences:
202.76 ms | 406 KiB | 354 Q