testing - Nothing is returned when trying to test php function -


i trying test function in browser, nothing returned. accessed link http://localhost/myfunctions.php?runfunction=writejson
function is:

function writejson() {     $myfile="testson.json";     $fileout=fopen($myfile,'w') or die("fatal: can't open json file writing");     global $arrayforjson;     if(isset($arrayforjson))     {         fwrite($fileout,json_encode($arrayforjson));         echo "done";     }     else echo "error: not write json file";     fclose($myfile); } 

where mistaken, proper way test function, or doing wrong?

the function not seem run, since no "done" or "error: not write json file" shown, nor changes made file.

if want run function via need include code get...

//this function function writejson() {     $myfile="testson.json";     $fileout=fopen($myfile,'w') or die("fatal: can't open json file writing");     global $arrayforjson;     if(isset($arrayforjson))     {         fwrite($fileout,json_encode($arrayforjson));         echo "done";     }     else echo "error: not write json file";     fclose($myfile); }   // call function if ?runfunction=writejson //is on end of url if(!empty($_get["runfunction"])){     if($_get["runfunction"] == "writejson"){         writejson(); // line actual call function     } } 

but of course, if want run every time go page add

writejson(); 

Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -