Jump to content

[SOLVED] Acceptable Special Characters in Code


ratgurrl

Recommended Posts

I have what is probably a very easy question:

 

When writing php code what special characters are acceptable and which are not.  For instance, I am in the habit of using the decimal code instead of the character/symbol itself when outputting html.

 

Example:

 

? for ?

& for &

= for =

 

I find for XHTML strict, the decimal code is necessary for the ampersand symbol, but not for the equal and question mark.

 

What is the best coding standard for this?  I am finding differing information and samples when it comes to this.

 

Should I always use the decimal when outputting html, or is it ok to use the question mark and equal sign to output?

 

Jennifer

 

 

 

 

Link to comment
Share on other sites

If you're asking whether or not it's fine to use the HTML equivalents of certain symbols...then your answer is yes. Your HTML should in fact be kept completely separate from your PHP so, it shouldn't even be a problem & you should stick to your strict XHTML coding practices. I encourage you to look into classes (OOP) and maybe use a templating class to load your HTML separately using methods, instead of intertwining everything into one messy 90,000 line script. Of course it's all relative. When coding a simple short PHP page, it isn't a big deal...and classes aren't really needed (Unless you go into complex functionality or whatever).

Link to comment
Share on other sites

Yes, I need to learn about OOP (just bought a book) and using classes.  I definitely want to expand my knowledge from the basics.   For now I want to make sure I'm writing the best code I can (and as clean and neat as possible) so it's easier to migrate it later once I learn more.

 

I appreciate your reply!

 

Jennifer

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.