PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Hey guys sorry for another question i keep running into issues...
Right now im building a form validator, a javascript one reads the forms first and if it works it loads a php code to check them.
I tested it and it works pretty good, however it is a seperate file named...shipping.php. Now it is a mix of html and php for example most of the start is html but the php code is at the end when the submit button is pressed. however i want to include this into my main layout code which is all php. This is the issue...
kyoru wrote:this is hard to describe...I cannot include it because it is and include file already so i need to somehow make it a variable...
main page < includes sub menu < includes the form validation
i'll try to function, that way i can call it but still include the code avoiding the quotes i think thank you!
You can include a page, and then include another page inside the included page.
thats not the real issue but the content are in variables...and only the first page has the echo statement, but the include of the include has php code in it with single quotes so the backslashes will be echoed making the code useless
I am not a big fan of eval either, but it appears that the sugestions that have been offered thus far have not been to this developers satisfaction. My thought is that he is probably using this code as part of an IF check, which would not necessarily require the code to be thrown into a variable but can be directly executed. If he can't include it in an include and he can't run it out of a function, then the next easiest, albeit more insecure, way to achieve what he wants is by eval.
I do agree that he should find a different way to execute this code.
I don't get this. Please explain what you are trying to acheive because every way I've looked at it just doesn't make any sense. What should be in the variable? the string or the result? I ask because there's nothing returned from what I can see, so even a function would be pointless if it's supposed to assign to a variable
If you explain a little further what the goal is we should be able to offer more solid solutions
Note: Your syntax for the switch construct is wrong. It should be:
i figured out the problem my self, because the variable has single quotes in it i entered the backslashes to escape them, i figured that the baclk slashes would be printed out when i echo them rendering my php code useless, but i overthinked it and it turns out i was wrong
kyoru wrote: i figured out the problem my self, because the variable has single quotes in it i entered the backslashes to escape them, i figured that the baclk slashes would be printed out when i echo them rendering my php code useless, but i overthinked it and it turns out i was wrong