programguru Posted January 15, 2009 Share Posted January 15, 2009 i am facing a strange issue which is new to me, and i have been unable to resolve for some days now. i ran various tests and read the manuals but this "issue" i am having was not covered. i am assuming it is something i am doing incorrect, but nothing is adding up. first off i am very familiar with the require_once function, and use it all the time, so here is what's happening: i am including a file into my main static php page. the file i am including has and if and else which the closing bracket for the else statement is in the static file. i have tested the file in full w/out the require_once, include, etc... and it works perfect, but any way i try this with the including i get the following standard "wrong place!" error. Parse error: syntax error, unexpected $end in C:\www\inc\header.php on line 70 and im sure the include is working because the line number 70 is correct (when the include file and static file lines are counted) in the error, so the file is surely being pulled in. does anyone know if i am just screwing up the whole point? or totally missing something here? is it a known bug? Link to comment https://forums.phpfreaks.com/topic/140988-solved-using-require-require_once-include-etc-but-if-and-else-interuption/ Share on other sites More sharing options...
PFMaBiSmAd Posted January 15, 2009 Share Posted January 15, 2009 You cannot split a language construct like an if/else statement with part of it in an include file and part of it in the main file. Link to comment https://forums.phpfreaks.com/topic/140988-solved-using-require-require_once-include-etc-but-if-and-else-interuption/#findComment-737895 Share on other sites More sharing options...
programguru Posted January 15, 2009 Author Share Posted January 15, 2009 You cannot split a language construct like an if/else statement with part of it in an include file and part of it in the main file. PFMaBiSmAd , thanks for the easy answer. I was beating myself up on experiments, and truthfully it was hard to believe it was not possible. Is this documented in the manual somewhere that you are aware of? I could not find it on php.net. Maybe php 7 will be more kind to if/else includes! Link to comment https://forums.phpfreaks.com/topic/140988-solved-using-require-require_once-include-etc-but-if-and-else-interuption/#findComment-737904 Share on other sites More sharing options...
dennismonsewicz Posted January 15, 2009 Share Posted January 15, 2009 my question is, why do you want to split if/else statements across includes? Link to comment https://forums.phpfreaks.com/topic/140988-solved-using-require-require_once-include-etc-but-if-and-else-interuption/#findComment-737906 Share on other sites More sharing options...
PFMaBiSmAd Posted January 16, 2009 Share Posted January 16, 2009 Whatever you think your application needs by splitting the syntax of one statement between a main file and an include file is the wrong approach. Find a different way of organizing your logic. Link to comment https://forums.phpfreaks.com/topic/140988-solved-using-require-require_once-include-etc-but-if-and-else-interuption/#findComment-738341 Share on other sites More sharing options...
programguru Posted January 16, 2009 Author Share Posted January 16, 2009 Whatever you think your application needs by splitting the syntax of one statement between a main file and an include file is the wrong approach. Find a different way of organizing your logic. What I am doing is very unique, and it's not usual to try something like this. But I would be interested in the correct "logic". Please elaborate in detail a better method? I am not sure how anyone would know the logic is "bad" if they have no idea what I am doing in the first place. Link to comment https://forums.phpfreaks.com/topic/140988-solved-using-require-require_once-include-etc-but-if-and-else-interuption/#findComment-738454 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.