MarioApprentice Posted November 28, 2012 Share Posted November 28, 2012 Hey everyone, i have a basic question. I've downloaded xampp and have been going trough Programming PHP book and found that embedding php in html is a problem. I've googled this and im doing everything right. ive alo copy/pasted some code that should work but it doesn't. <head> </head> <body> <p>This is written but this [code=php:0]this is not[/code] </p> </body> </html> The question is newbie. The php output is not showing on my browser. The file is php extension not html, its in the right tags and it wont show. Also, when i embedd a HTML element inside echo, that shows but with an this: "?>. Like this <p> <?php echo "<p>Hey</p>"?> </p> This would output Hey but with addiotional "?> in a newline. Thank you for all your answers. Quote Link to comment https://forums.phpfreaks.com/topic/271289-newb-problem/ Share on other sites More sharing options...
Beeeeney Posted November 28, 2012 Share Posted November 28, 2012 Hey everyone, i have a basic question. I've downloaded xampp and have been going trough Programming PHP book and found that embedding php in html is a problem. I've googled this and im doing everything right. ive alo copy/pasted some code that should work but it doesn't. <head> </head> <body> <p>This is written but this [code=php:0]this is not[/code] </p> </body> </html> The question is newbie. The php output is not showing on my browser. The file is php extension not html, its in the right tags and it wont show. Also, when i embedd a HTML element inside echo, that shows but with an this: "?>. Like this <p> <?php echo "<p>Hey</p>"?> </p> This would output Hey but with addiotional "?> in a newline. Thank you for all your answers. Can you post your full code? You've probably not closed some quotation marks somewhere. Quote Link to comment https://forums.phpfreaks.com/topic/271289-newb-problem/#findComment-1395852 Share on other sites More sharing options...
MarioApprentice Posted November 28, 2012 Author Share Posted November 28, 2012 ok. here it is for copy/paste <!doctype html> <html> <head> <title>This is my first PHP program!</title> </head> <body> <p>This is going to be ignored by PHP and displayed by the browser.</p> <?php echo 'While this is going to be parsed.'; ?> <p>This will also be ignored by PHP and displayed by the browser.</p> </body> </html> Here it is. This is an example from google by some website. They are all the same but none of them works on me. Quote Link to comment https://forums.phpfreaks.com/topic/271289-newb-problem/#findComment-1395853 Share on other sites More sharing options...
Beeeeney Posted November 28, 2012 Share Posted November 28, 2012 ok. here it is for copy/paste <!doctype html> <html> <head> <title>This is my first PHP program!</title> </head> <body> <p>This is going to be ignored by PHP and displayed by the browser.</p> <?php echo 'While this is going to be parsed.'; ?> <p>This will also be ignored by PHP and displayed by the browser.</p> </body> </html> Here it is. This is an example from google by some website. They are all the same but none of them works on me. There's no reason for that not to work. You ARE opening your .php files on your local server, right? Quote Link to comment https://forums.phpfreaks.com/topic/271289-newb-problem/#findComment-1395854 Share on other sites More sharing options...
Christian F. Posted November 28, 2012 Share Posted November 28, 2012 Are you going via your local web server, or are you opening the page directly in your browser? Quote Link to comment https://forums.phpfreaks.com/topic/271289-newb-problem/#findComment-1395855 Share on other sites More sharing options...
Beeeeney Posted November 28, 2012 Share Posted November 28, 2012 Just to clarify for him: That'll probably be localhost/foldername/filename.php or something similar. Quote Link to comment https://forums.phpfreaks.com/topic/271289-newb-problem/#findComment-1395858 Share on other sites More sharing options...
MarioApprentice Posted November 28, 2012 Author Share Posted November 28, 2012 Yes, I am. Also Also, when I put <p> inside echo it works but alone it doesnt. <!doctype html> <html> <head> <body> <?php echo "doesn't work"?> <p> <?php echo"<p>Works</p>";?> </p> </body> </head> </html> At the end, the only thing that outputs is ";?> and thats it. Quote Link to comment https://forums.phpfreaks.com/topic/271289-newb-problem/#findComment-1395859 Share on other sites More sharing options...
MarioApprentice Posted November 28, 2012 Author Share Posted November 28, 2012 and im running it on local server and yes its and it is loclachost/htdocs/file.php Quote Link to comment https://forums.phpfreaks.com/topic/271289-newb-problem/#findComment-1395860 Share on other sites More sharing options...
Beeeeney Posted November 28, 2012 Share Posted November 28, 2012 Works absolutely fine. It must be something you're doing. Quote Link to comment https://forums.phpfreaks.com/topic/271289-newb-problem/#findComment-1395861 Share on other sites More sharing options...
MarioApprentice Posted November 28, 2012 Author Share Posted November 28, 2012 yea must be. Thanks for your time Quote Link to comment https://forums.phpfreaks.com/topic/271289-newb-problem/#findComment-1395863 Share on other sites More sharing options...
Muddy_Funster Posted November 28, 2012 Share Posted November 28, 2012 so you are opening your browser and going to http://localhost/file.php correct? What program are you using to create your .php files? did you get something like notepad++/pspad/eclipse or are you using ms word or some such? Quote Link to comment https://forums.phpfreaks.com/topic/271289-newb-problem/#findComment-1395864 Share on other sites More sharing options...
MarioApprentice Posted November 28, 2012 Author Share Posted November 28, 2012 no, ive created another folder localhost/htdocs/start/file.php but that shouldt me a problem, right? Ive been doing that with php code without html and it works. Im using just notepad. Quote Link to comment https://forums.phpfreaks.com/topic/271289-newb-problem/#findComment-1395867 Share on other sites More sharing options...
Beeeeney Posted November 28, 2012 Share Posted November 28, 2012 Should probably download an editor with syntax highlighting. Helps out a lot. Can you post a screenshot of your editor right next to the page it's producing? One where we can see the address bar. Quote Link to comment https://forums.phpfreaks.com/topic/271289-newb-problem/#findComment-1395868 Share on other sites More sharing options...
MarioApprentice Posted November 28, 2012 Author Share Posted November 28, 2012 hey, it works but all i did is close the tab that i was working in and executed the file the same way i did the las 100 times. I didnt change anything. Sorry for the false alarm Quote Link to comment https://forums.phpfreaks.com/topic/271289-newb-problem/#findComment-1395869 Share on other sites More sharing options...
Beeeeney Posted November 28, 2012 Share Posted November 28, 2012 Good stuff. Quote Link to comment https://forums.phpfreaks.com/topic/271289-newb-problem/#findComment-1395870 Share on other sites More sharing options...
Beeeeney Posted November 28, 2012 Share Posted November 28, 2012 Your image doesn't seem to be working. Quote Link to comment https://forums.phpfreaks.com/topic/271289-newb-problem/#findComment-1395879 Share on other sites More sharing options...
Christian F. Posted November 28, 2012 Share Posted November 28, 2012 He's a spambot, ignore it. Quote Link to comment https://forums.phpfreaks.com/topic/271289-newb-problem/#findComment-1395880 Share on other sites More sharing options...
Beeeeney Posted November 28, 2012 Share Posted November 28, 2012 I see. Quote Link to comment https://forums.phpfreaks.com/topic/271289-newb-problem/#findComment-1395882 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.