₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,327,357 members, 8,430,637 topics. Date: Saturday, 20 June 2026 at 07:45 PM

Toggle theme

Explanation Needed In PHP - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingExplanation Needed In PHP (1093 Views)

1 Reply (Go Down)

Explanation Needed In PHP by paranorman(op): 5:16pm On Jun 11, 2017
 //give te script time to execute
ini_set("max_execution_time", 200);

$portRange = range(0, 1023);
$host = "127.0.0.1";

print "<p>The scan results for $host is:</p>";
//execute the scan
foreach ($portRange as $port) {
if ($result = @fsockopen($host, $port, $errNo, $errString, 1)) {
$service = getservbyport($port, 'tcp');
print "Socket open at port $port, with <em><strong>$service</strong></em> service <br />";
}
} //end loop


The code above works just fine because wrote '@' beside the fsockopen() function. Removing the '@' produces error as seen in the screen shots. Why is the @ compulsory? what it actually does?

Thanks in anticipation of your replies.

Re: Explanation Needed In PHP by Caustics: 5:19pm On Jun 11, 2017
cool
Re: Explanation Needed In PHP by Echatbook: 6:21pm On Jun 11, 2017
paranorman:
 //give te script time to execute
ini_set("max_execution_time", 200);

$portRange = range(0, 1023);
$host = "127.0.0.1";

print "<p>The scan results for $host is:</p>";
//execute the scan
foreach ($portRange as $port) {
if ($result = @fsockopen($host, $port, $errNo, $errString, 1)) {
$service = getservbyport($port, 'tcp');
print "Socket open at port $port, with <em><strong>$service</strong></em> service <br />";
}
} //end loop


The code above works just fine because wrote '@' beside the fsockopen() function. Removing the '@' produces error as seen in the screen shots. Why is the @ compulsory? what it actually does?

Thanks in anticipation of your replies.
Basically using the @sign will cause all php warnings not to be shown for that particular function.
Re: Explanation Needed In PHP by nsimageorge(m): 6:48pm On Jun 11, 2017
http://php.net/manual/en/language.operators.errorcontrol.php

Like Echatbook said, the @silences errors for a function(read the php manual above)

If you don't mind me asking what exactly whee you trying to achieve with your function. It would be best to write a bug free code.
Re: Explanation Needed In PHP by paranorman(op): 8:09pm On Jun 11, 2017
I appreciate your contributions. Thanks
1 Reply

I Need Online Banking Source Code In PHP, MSQLOnline Banking Source Code In PHP, MSQL234

Please, Help Me, Damaged File Adobe PhotoshopVanhack Talent Accelerator Africa (feb 2018) Apply Now!I Don't Know Where To Start..somebody Help!!!!