Date

Hello, I am new to PHP but I am ok at coding using Xhtml and CSS. I am trying to learn PHP and decided to incorporate little bits of PHP into my website (website in the making still on local host) before I went all out with forms and stuff. All I am trying to do is display the date. When I put the php code in below 2 things happen. 1st is on my local host on the top left side this happens “?»?” (inside the quotes). This is rather anoying looking, but the date does appear correctly. When I view it in firefox and IE with the PHP coding in it screws up some stuff like font size…? I don’t know whats going on there except you are only supposed to be able to see php in a local host or server that supports php correct?

Anyway my basic question is am I doing the code right? And what is making the ?»? appear.

Hear is my code…

Goldfish Graphics
"Goldfish
Home         Services         Portfolio         Contact

Testimonies

""




Home

Example

News (<?PHP echo date("D M d, Y"); ?>)

Edample

Your PHP code looks correct. To get rid of those crazy characters I would try removing all at the top:

and Replace with the just the simple…

and see if this makes any kind of a difference.

I don’t think thats the problem. If I veiw my page without the Php in my browser it looks fine. All that mumbo jumbo is what makes my page W3 xhtml strict compliant. I actually just tried it and it didn’t work. Any other suggestions?

I see what you mean. When I look at the source code from the local host those symbols are in front of the doc type. When I look at it on my D drive. It isn’t there… How do I edit something thats not there?

What code editor are you using?? I seem to remember having this problem back when I first stated out and I think it was due to me using a standard wordpad that comes with Microsofts OS’s.

If you are using this or something like it copy code to just a plain textpad doc. Save and try it then. Let us know if that works or how you solve it so if others have this problem we can find the answer! :)

Thanks.

Are you using Firefox? I just got this exact thing happening to me today. I noticed it didn’t happen in IE. I working on a solution as to why these characters show up in Firefox and not IE.

Ya I copied all my text and pasted it into a new doc. It worked. What the heck that makes no sense, but yes I was using like the standard word pad or whatever.

I found that a lot of times wordpad and such editors throw in invisible characters that mess with the HTML renderer.

I only figured it out because I add a page that was working fine and needed a quick change and I used wordpad to make the quick change and all of a sudden I was getting crazy characters. So I figured it had to be something do with the editor and tried the Notepad. And it fixed.

You should try…

Notepad++ I like this with the color coding and the best part is it is free.

http://notepad-plus.sourceforge.net/uk/site.htm

Its pretty handy and has code hinting for PHP and HTML.

Sponsor our Newsletter | Privacy Policy | Terms of Service