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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.