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!
no, but in your case that is not the problem, you do not need to redeclare <?php inside your echos. you can swing in and out of php/html as many times, just take care not to loose step.
so the question really is not wether echo can execte php, but rather, are you in php or in html ? <?php brings you into php ?> escapes you from php into html.
and it would help much if you get an editor with syntax highlighter capability.
However, in srednatonmi's case, php_east was right, you were already inside php tags when used echo. You probably just need an if statement and echo everything inside it.
yes, the if { ?> HTML <?php } ?> is normally used to induce PHP driven html output based on true/false. so i will disregard your remark, don't want to confuse @srednatonmi which works and which won't.
The example i posted applies. i was just trying to show @srednatonmi how to wiggle in and out of PHP/HTML, and this i think would be among the more difficult concepts to adjust to for one learning PHP. but certainly the most useful one and perhaps essential.
yes, the if { ?> HTML <?php } ?> is normally used to induce PHP driven html output based on true/false. so i will disregard your remark, don't want to confuse @srednatonmi which works and which won't.
The example i posted applies. i was just trying to show @srednatonmi how to wiggle in and out of PHP/HTML, and this i think would be among the more difficult concepts to adjust to for one learning PHP. but certainly the most useful one and perhaps essential.
Gotcha, thanks Guess I'm too old school sometimes haha
php_east wrote:
well i suppose you could, but hmmpph, i don't know. it just doesn't seem right.
I think it is absolutely right depending on the circumstances of course. It allows for much more concise and compact code. Which I hope everyone can agree is a good thing. This isn't something someone starting just starting out would be doing, but is a technique that should eventually be used.
JasonDFR wrote:I think it is absolutely right depending on the circumstances of course. It allows for much more concise and compact code. Which I hope everyone can agree is a good thing. This isn't something someone starting just starting out would be doing, but is a technique that should eventually be used.
i understand what you say, but got thrown off track when i read the example.
do you mean is it better to code as in your first example better than ( as opposed to ) in your second. it contradicts your statement abut consice clear codes. the first one is clear to me, but the second is more concise. so i'm a little dizzy
Yeah, I probably should have put the second piece of code first. You're right, the as opposed to makes my point a bit blurry.
My point was to respond to you saying, "just doesn't seem right". I think that depending on the circumstances, evaluating code inside an echo statement can be a better way to go.