PHP, 157 105/87 102/87 100/85
<?php function l($q){return file_get_contents("https://google.ca/search?btnI&q=".rawurlencode($q));}
Không cho phép khoảng trắng trong cụm từ tìm kiếm, nó chỉ có 87 ký tự:
<?php function l($q){return file_get_contents("https://google.ca/search?q=$q&btnI");}
Phiên bản gốc sử dụng cURL
Tôi cho rằng cú pháp mảng ngắn có thể được sử dụng trên PHP 5.4+:
<?php function l($q){$ch=curl_init("https://google.ca/search?btnI=1&q=".rawurlencode($q));curl_setopt_array($ch,[19913=>1,52=>1]);return curl_exec($ch);}
Mặt khác, đó là năm ký tự nữa với trình khởi tạo mảng thông thường, 162:
<?php function l($q){$ch=curl_init("https://google.ca/search?btnI=1&q=".rawurlencode($q));curl_setopt_array($ch,[19913=>1,52=>1]);return curl_exec($ch);}
Phiên bản không cho phép khoảng trắng trong cụm từ tìm kiếm : Không cần mã hóa URL (138):
<?php function l($q){$ch=curl_init("https://google.ca/search?q=$q&btnI=1");curl_setopt_array($ch,[19913=>1,52=>1]);return curl_exec($ch);}
Sử dụng hằng số
<?php
function l($q){
$ch = curl_init("https://google.ca/search?btnI=1&q=" . rawurlencode($q));
curl_setopt_array($ch, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_FOLLOWLOCATION => 1
));
return curl_exec($ch);
}
gogle.dethậm chí tồn tại?