ricmetal Posted July 11, 2012 Share Posted July 11, 2012 interessting the fact that the POST var in REQUEST_METHOD is called before any other variable on a script, no matter where these are placed. is this true? am i doing something wrong here? im inluding a few config variables on the very top of my webpage and calling an if statement to check in a POST request has been made way after these config variable are set. yet, the REQUEST_METHOD POST if statement check (which needs some of these config variables to run successfully) fails. could someone please point me to reading material on this 'read' order? thanks Quote Link to comment https://forums.phpfreaks.com/topic/265513-reading-material-regading-request-method-var-order/ Share on other sites More sharing options...
Adam Posted July 11, 2012 Share Posted July 11, 2012 I'm not sure I follow? $_SERVER['REQUEST_METHOD'] contains a string. This value is define before any of your code runs, but any uses of it will only be evaluated in line with the normal flow. There's no special parsing of it, to the best of my knowledge. I would guess the problem lies elsewhere in your logic. Can you post an example reproducing the issue you're talking about? Quote Link to comment https://forums.phpfreaks.com/topic/265513-reading-material-regading-request-method-var-order/#findComment-1360741 Share on other sites More sharing options...
ricmetal Posted July 11, 2012 Author Share Posted July 11, 2012 hi, yeah i'm running an if statement to include a php script, depending on if $_SERVER['REQUEST_METHOD'] equals POST. this included php script needs the config variables i was talking about, include at the top of the page. and this if statement is called after these config vars are included. the included php script which is included due to the server request method being post needs the config variables, yet it appears it doesn't find them, like they don't exist yet. also, if i run a print in this included php script, and another in the config vars php file included at the top of the page, the print that appears first is the included php script from the server method request if statement. something like include 'config.php'; // holds variables and the print statement // outputs 'config vars here' if($SERVER['REQUEST_METHOD' == 'POST']) { include 'anotherPHPscript.php'; } // holds a print that outputs 'server request method queried<br>' my webpage has a form submit button that submits to the same webpage. the output of the above, on submit is: server request method queried config vars here so this should not be happening you say? regards Quote Link to comment https://forums.phpfreaks.com/topic/265513-reading-material-regading-request-method-var-order/#findComment-1360742 Share on other sites More sharing options...
cpd Posted July 11, 2012 Share Posted July 11, 2012 I don't really understand what your asking but I can see straight away your code has errors. 1) $SERVER is non-existent unless you've created it. I'll assume you mean $_SERVER with an underscore. 2) Your trying to compare something inside the array index identifier section of your code: $SERVER['REQUEST_METHOD' == 'POST']. This should read as follows: $_SERVER['REQUEST_METHOD'] == 'POST' Quote Link to comment https://forums.phpfreaks.com/topic/265513-reading-material-regading-request-method-var-order/#findComment-1360745 Share on other sites More sharing options...
ricmetal Posted July 11, 2012 Author Share Posted July 11, 2012 yeah cpd two type mistakes in the post. sorry bout that. i've made a simple example of what im trying to do, and it runs fine so there must be something i'm missing in my code thats producing the issue i am having. back to the choping block. regards Quote Link to comment https://forums.phpfreaks.com/topic/265513-reading-material-regading-request-method-var-order/#findComment-1360746 Share on other sites More sharing options...
Adam Posted July 11, 2012 Share Posted July 11, 2012 ^ What CPD said. Despite those errors though, there's still no reason why 'anotherPHPscript.php' would be executed first. Is that the exact code you have? Edit: seen your latest post. I would suggest posting the exact code. Quote Link to comment https://forums.phpfreaks.com/topic/265513-reading-material-regading-request-method-var-order/#findComment-1360747 Share on other sites More sharing options...
ricmetal Posted July 11, 2012 Author Share Posted July 11, 2012 sorry. im a dumb ass that lacks the concentration to keep order of includes. lol thanks for the info on 'possibly no order' policy on the $_SERVER var call order regards Quote Link to comment https://forums.phpfreaks.com/topic/265513-reading-material-regading-request-method-var-order/#findComment-1360750 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.