Sponsored Content
Full Discussion: PHP function kills my code?
Top Forums Shell Programming and Scripting PHP function kills my code? Post 44874 by l008com on Thursday 11th of December 2003 07:11:36 PM
Old 12-11-2003
PHP function kills my code?

So I'm making a page for one of my web sites that scans the visitors ports (just a few specific ones, not ALL) and tells them if they have any open. Now I made up the code and it worked great. Now instead of having the same chunk of code all over my script, I tried to make my own subroutine so I could just call it from all over. But since I did that, it now gives me an error of type 0, which means it couldn't even try to connect to the host, before it got an error. I can't figure it out at all?

Here's my code
PHP Code:
<? function sniff( $portnumber ) {
         if (! $sock = fsockopen($REMOTE_ADDR, $portnumber, $errno, $errstr, 7) )
             {
              if ($errno == 60)
                  {
                  echo "Timeout";
                  }
                  else 
                  {
                  echo "Closed $errno";
                 }
            }
            else
            {
              echo "<font color=#ff3300>Open</font>";
              fclose($sock);
              }
      } ?>
And here is how I call the function...
PHP Code:
<? sniff(22); ?>
I'm new to writing php's, but I don't think I have any syntax problems?
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

exit from telnet kills orbix process

Hi, I'm using a bourne shell to kick off a 3rd Pty app. This app uses Orbix. When I exit from the telnet session which started the app or hit CTRL-C at the command line, the orbix process dies, yet all other process remain. I've tried starting the app as a background process, but it still... (1 Reply)
Discussion started by: edgarm
1 Replies

2. UNIX for Dummies Questions & Answers

Crash Kills Printer Device

A user accidentally unplugged her server from the wall. She has rebooted twice, but the system does not recognize the default printer device, which previously was lp02. There is a file which reads /dev/lp0 and then garble. I'm a total newbie at all of this, with some Unix experience many,... (2 Replies)
Discussion started by: ckurt
2 Replies

3. SuSE

Linux kills windows :(

Hey all, I've tired installing Suse 9.2 (DVD) on my computer, dual boot. But everytime I do it Linux seems to kill my Windows install. This is my setup, a 120GB HDD and for 30GB for Windows 60GB for Data and 30 GB for Linux. Windows works fine, then install SuSe and that works fine. ... (6 Replies)
Discussion started by: woofie
6 Replies

4. Shell Programming and Scripting

application exit kills shells

Hi all, I start my application from a shell command-line. When I exit my application, it kills the shell that its returning too. Worse yet, since I have init respawning the shell all those subsequent shells get killed automatically...so I get output like the following (the >> is the prompt for... (2 Replies)
Discussion started by: q1001001
2 Replies

5. UNIX for Dummies Questions & Answers

Exiting eXceed window kills my process

Hi, I run a binary application with GUI accessibility. To launch and close the application i follow the following steps: 1.Log into a console session. Export display to the local workstation. 2.Launch X windows app ( eXceed ) 3.From terminal session go to the my application directory and... (2 Replies)
Discussion started by: shantaputi
2 Replies

6. UNIX for Dummies Questions & Answers

kills command

what are the header files required for the kills command in kernel version 2.4? (1 Reply)
Discussion started by: shwe
1 Replies

7. Shell Programming and Scripting

Script, child kills parent

Hello everyone, I'm trying to write a script, i would like to say the child kills the parent, how would i do that? (2 Replies)
Discussion started by: jessy21
2 Replies

8. UNIX for Dummies Questions & Answers

xend kills network connectivity on boot

red hat 5 update 4 64bit. linux newby. on an interactive boot i can ping -t my vm linux server from my physical MS XP workstation and a vm W2000 64 bit server until xend is started, after that i get destination unreachable. if i choose not to start xend on the interactive boot i retain... (1 Reply)
Discussion started by: slartibartfast9
1 Replies

9. UNIX for Advanced & Expert Users

A Program Which Generates a Script Which Kills It

I have a C++ program, running on Fedora Linux, which has to be able to update itself to a new version, which it can obtain from a server. The way I do this is to have it create a shell script which kills it (the parent process), uninstalls it, downloads the new version (actually it does this... (1 Reply)
Discussion started by: BrandonShw
1 Replies
EVAL(3) 								 1								   EVAL(3)

eval - Evaluate a string as PHP code

SYNOPSIS
mixed eval (string $code) DESCRIPTION
Evaluates the given $code as PHP. Caution The eval(3) language construct is very dangerous because it allows execution of arbitrary PHP code. Its use thus is discouraged. If you have carefully verified that there is no other option than to use this construct, pay special attention not to pass any user provided data into it without properly validating it beforehand. PARAMETERS
o $code - Valid PHP code to be evaluated. The code mustn't be wrapped in opening and closing PHP tags, i.e. 'echo "Hi!";' must be passed instead of '<? echo "Hi!"; >'. It is still possible to leave and reenter PHP mode though using the appropriate PHP tags, e.g. 'echo "In PHP mode!"; ?>In HTML mode!<? echo "Back in PHP mode!";'. Apart from that the passed code must be valid PHP. This includes that all statements must be properly terminated using a semicolon. 'echo "Hi!"' for example will cause a parse error, whereas 'echo "Hi!";' will work. A return statement will immediately terminate the evaluation of the code. The code will be exe- cuted in the scope of the code calling eval(3). Thus any variables defined or changed in the eval(3) call will remain visible after it terminates. RETURN VALUES
eval(3) returns NULL unless return is called in the evaluated code, in which case the value passed to return is returned. If there is a parse error in the evaluated code, eval(3) returns FALSE and execution of the following code continues normally. It is not possible to catch a parse error in eval(3) using set_error_handler(3). EXAMPLES
Example #1 eval(3) example - simple text merge <?php $string = 'cup'; $name = 'coffee'; $str = 'This is a $string with my $name in it.'; echo $str. " "; eval("$str = "$str";"); echo $str. " "; ?> The above example will output: This is a $string with my $name in it. This is a cup with my coffee in it. NOTES
Note Because this is a language construct and not a function, it cannot be called using variable functions. Tip As with anything that outputs its result directly to the browser, the output-control functions can be used to capture the output of this function, and save it in a string (for example). Note In case of a fatal error in the evaluated code, the whole script exits. SEE ALSO
call_user_func(3). PHP Documentation Group EVAL(3)
All times are GMT -4. The time now is 05:26 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy