Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,207,779 members, 8,000,272 topics. Date: Tuesday, 12 November 2024 at 07:07 AM

Explanation Needed In PHP - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Explanation Needed In PHP (1048 Views)

Online Courier Management System Developed In Php/mysql. (quadruple Logistics) / I Need Online Banking Source Code In PHP, MSQL / Online Banking Source Code In PHP, MSQL (2) (3) (4)

(1) (Reply) (Go Down)

Explanation Needed In PHP by paranorman(m): 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.

1 Like

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.

1 Like

Re: Explanation Needed In PHP by paranorman(m): 8:09pm On Jun 11, 2017
I appreciate your contributions. Thanks

(1) (Reply)

Which Is Correct / Use A Servo Motor With Arduino / Please Where Can I Start Off My Professional Career

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 16
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.