SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Dec 2000
    Location
    Norcross, GA
    Posts
    136
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    	$name = "me";
    	$fileopened = fopen ("test.txt", "a+");
    	$fwrite ($fileopened, $name"); 
    	fclose ($fileopened);
    Any idea on why this script would produce a 'call to undefined function on line 3' errror? (line three being the fwrite line)

    Thanks.

    (ps, I've used fputs() and it produced the same error)
    - Mike
    http://www.georgiaoffroad.com

  2. #2
    SitePoint Zealot
    Join Date
    Dec 2000
    Location
    Norcross, GA
    Posts
    136
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just tried the same script on a different server, still getting the call to undefined function error. Both servers use php4.
    - Mike
    http://www.georgiaoffroad.com

  3. #3
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    lose the $ character

    $fwrite ($fileopened, $name");

    shoud be

    fwrite ($fileopened, $name");


  4. #4
    Grumpy Mole Man Skunk's Avatar
    Join Date
    Jan 2001
    Location
    Lawrence, Kansas
    Posts
    2,066
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yup - interestingly enough the reason you got a "undefined function" error rather than a standard syntax error is that the line:

    $fwrite ($fileopened, $name);

    Could actually mean something. This is due to PHP allowing you to use variable function names. The following code is perfectly legal:

    $string = "fwrite";
    $string ($fileopened, $name);

    The above is exactly the same as this:

    $string ($fileopened, $name);

    It's an interesting feature this - I'm sure it could be useful although I've never felt it necessary to use it.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •