תשתמש עם if אחד כל פעם
ורצוי שגם תשתמש ב empty
EX:
PHP קוד:
$port['http'] = 80;
$port['ftp'] = 21;
function check($url, $act) {
global $port;
if(empty($url)) {
echo "Error!";
} else {
return $url . ":" . $port[$act];
}
}
function returninfo($url, $act, $return) {
$explode = explode(":", check($url, $act));
if($retrun == "ip") {
return $explode[0];
} elseif($return == "port") {
return $explode[1];
}
}
echo "IP: " . returninfo($http, "http", "ip");
echo "Port: " . returninfo($http, "http", "ip");
בוא נגיד שהתחשק לי להשקיע בך.
זה אמור לעשות לך את הבדיקה, ולהוציא את ה IP והפורט ע"י פונקצייה אם זה לא ריק, תשתמש בזה אם בא לך...
*עריכה: זה היה ארוך יותר וקיצרתי עכשיו
