flusho Posted May 7, 2007 Share Posted May 7, 2007 Hi, I am having trouble recieving output from my function getcf.php, I have tried outputting using the print_r() and count() to check the output but no luck just a blank page here is the code: <?php function getcf($catalogFile) { if (file_exists($catalogFile)) { $data = file($catalogFile); foreach ($data as $line) { $lineArray = explode(':', $line); $sku = trim($lineArray[0]); $CATALOG[$sku]['desc'] = trim($lineArray[1]); $CATALOG[$sku]['price'] = trim($lineArray[2]); } } else { die("Could not find catalog file"); } } return $CATALOG; ?> being called from and returned to print catalog.php here: <?php include("/usr431/home/d/r/dr34521/public_html/test/getcf.php"); //invoke function getcf $cstring = 'catalog.dat'; getcf($cstring); print_r ($CATALOG); ?> I just get a blank page, rackin my brains trying figure it out... thanks, Flusho Link to comment https://forums.phpfreaks.com/topic/50421-solved-function-output-problem-blank-page/ Share on other sites More sharing options...
ToonMariner Posted May 7, 2007 Share Posted May 7, 2007 return should be th last line of your function (before the closing brace)... <?php function getcf($catalogFile) { if (file_exists($catalogFile)) { $data = file($catalogFile); foreach ($data as $line) { $lineArray = explode(':', $line); $sku = trim($lineArray[0]); $CATALOG[$sku]['desc'] = trim($lineArray[1]); $CATALOG[$sku]['price'] = trim($lineArray[2]); } } else { die("Could not find catalog file"); } return $CATALOG; } ?> then call it like this... <?php include("/usr431/home/d/r/dr34521/public_html/test/getcf.php"); //invoke function getcf $cstring = 'catalog.dat'; $catalog = getcf($cstring); print_r ($catalog); ?> try to reserve UPPCASE var for constants. Link to comment https://forums.phpfreaks.com/topic/50421-solved-function-output-problem-blank-page/#findComment-247659 Share on other sites More sharing options...
flusho Posted May 7, 2007 Author Share Posted May 7, 2007 Thanks Toon, that was killin me. Link to comment https://forums.phpfreaks.com/topic/50421-solved-function-output-problem-blank-page/#findComment-247674 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.