Jump to content

function question


Sanjib Sinha

Recommended Posts

I have two php pages titled index.php and method1.php

code of method1.php is

 

<?php

 

  function s($file = "myfile.html")

  {

 

    return ("$file");

  }

 

 

?>

 

and the code of index.php is

<?php

include ("method1.php");

?>

 

<?php

 

echo s(readfile("myfile.html"));

 

?>

 

The problem is readfile as a function executes fine but at the end a number 347 has come up. Why this happens?

Secondly, can any one tell me whether reading or writing file as function can be done this way, or it is wrong?

Link to comment
Share on other sites

I personally would use require instead of include. I use include when it is something that will display data and require when it is only functions. I think they are the same though, except for how they handle errors.

 

I also wouldn't use a file per function. I would make functions.php and put multiple ones in there.

 

The 347 sounds like something to do with the file. What is in myfile.html?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.