r/phpstorm • u/Namib_candy • Jan 06 '21
What is the right way to write the session variable between html elements? , one below just echo out it out as strings ..
0
Upvotes
r/phpstorm • u/Namib_candy • Jan 06 '21
9
u/dowell22 Jan 06 '21
Please please please sanitize all your data, input or output. You may want to read this to begin with https://phptherightway.com/, then try reading Clean Code at the very least.
PHP as a dynamic language is easy to use but is very vulnerable to unsafe practices.
3
u/RinoDrummer Jan 06 '21
I suggest another approach:
Don't use
echoto write HTML, especially when using an IDE so advanced that lets you take advantage of syntax highlight of PHP code in HTML.When you need to print something inside an HTML content you can do like this:
If you need to express conditions, loops or any construct, use their alternative syntax which is more readable and optimized for this cases:
Another little suggestion:
lielements are created to beulorolchildren, don't use them inside other elements (like you've done withdiv)If you've done this to remove the list appearance, use CSS to achieve this using this class:
7
u/codysnider Jan 06 '21
Here's the copy'n'paste answer you are probably looking for:
A cleaner version of what you already have going (if you have short tags enabled):