dormouse1976 Posted June 8, 2007 Share Posted June 8, 2007 Hi, I know its been a few years, and my php is rusty at best, but the following has me stumped. if i have a greater than symbol within a section of php code, embedded with the <body> section of a .html file, then when viewing the page, the parser jumps out of the php script, and displays the rest of the script as though normal html, until a less than symbol is encountered, and it then proceeds to behave as though php again. example <head> <title>My Brain Hurts!!</title> </head> <body> <?php $rbg = 0xFFFFFF; $r = ($rgb >> 16) & 0xFF; ?> </body> will display, when run from a browser > 16) & 0xFF; ?> Have i forgotten more than i think, and missing something rather obvious, or is something screwie going on? TIA, dormouse Quote Link to comment https://forums.phpfreaks.com/topic/54677-greater-than-problem-in-php-code-in-html-body/ Share on other sites More sharing options...
btherl Posted June 8, 2007 Share Posted June 8, 2007 I think your script is not being run as php. Check your browser configuration, or rename it to .php instead of .html Quote Link to comment https://forums.phpfreaks.com/topic/54677-greater-than-problem-in-php-code-in-html-body/#findComment-270407 Share on other sites More sharing options...
Dragen Posted June 8, 2007 Share Posted June 8, 2007 Your file must have a .php extension, not .html Quote Link to comment https://forums.phpfreaks.com/topic/54677-greater-than-problem-in-php-code-in-html-body/#findComment-270413 Share on other sites More sharing options...
dormouse1976 Posted June 8, 2007 Author Share Posted June 8, 2007 Thanks. Renaming file to .php has sorted the problem. I still find it strange that it jumps out of php, within the .html file, without the correct end syntax. ie ?> Quote Link to comment https://forums.phpfreaks.com/topic/54677-greater-than-problem-in-php-code-in-html-body/#findComment-270421 Share on other sites More sharing options...
Dragen Posted June 8, 2007 Share Posted June 8, 2007 it's not jumping in and out. The server picks up the < symbol as it's a basic html symbol for writing any code, so it assumes there is valid html after it and hides it to the browser. Just like <a> It doesn't display the 'a', but after the closing > it shows anything past that point. Quote Link to comment https://forums.phpfreaks.com/topic/54677-greater-than-problem-in-php-code-in-html-body/#findComment-270429 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.