3v4l.org

run code in 300+ PHP versions simultaneously
<?hh // 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 5.3.0 - 5.3.29, 5.4.0 - 5.4.32, 7.2.29 - 7.2.33, 7.3.16 - 7.3.31, 7.4.3 - 7.4.32, 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
<?hh // 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 8.0.13
Parse error: syntax error, unexpected token "function" in /in/TIf0m on line 3
Process exited with code 255.
Output for 7.3.32 - 7.3.33, 7.4.33
Parse error: syntax error, unexpected 'function' (T_FUNCTION) in /in/TIf0m on line 3
Process exited with code 255.

preferences:
160.83 ms | 401 KiB | 198 Q