khaibar 0 Report post Posted June 19, 2007 Hey ,In the note pad, I put the proper code for php<?php?>and save the file as name.phpBut i can't put that file in html. This is a big problem since Iam trying to make an online text based game. Whats the code to put a script inside a web page. And do i need any special software for it?If so where can i download it?Thanks for reading . Share this post Link to post Share on other sites
TavoxPeru 0 Report post Posted June 19, 2007 Hey ,In the note pad, I put the proper code for php<?php?>and save the file as name.phpBut i can't put that file in html. This is a big problem since Iam trying to make an online text based game. Whats the code to put a script inside a web page. And do i need any special software for it?If so where can i download it?Thanks for reading .You can't do this, instead what you do is to put the html code inside the php file, then in your browser when you run the php file you vie the output generated by. For example:<?php// simple example?><html><head><?phpecho "<title>Simple Example</title>\n";?></head><?phpecho "<body style=\"margin:0 auto;color:#900;\">\n" . "<p>Simple Example<br />Other texts....</p>\n";?></body></html>Best regards, Share this post Link to post Share on other sites
FirefoxRocks 0 Report post Posted June 20, 2007 Yes, PHP is designed to be integrated within HTML documents, with the file having a .php extension. So therefore, your code could look like this: <?php// Some scripts can even come before the HTML part of the document, like session scripts.?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd; <html xml:lang="en" lang="en" xmlns="www.w3.org/1999/xhtml/" page with PHP scripts</title></head><body><?php //Some scripts. ?><p>A paragraph in HTML</p><?php //Some more scripts. ?><p>Well, you get the idea.</p></body></html> So you don't make separate files for the PHP code, you just add them in the page. Share this post Link to post Share on other sites
iGuest 3 Report post Posted June 20, 2007 Also, on most servers, you cannot put php scripts in .htm/.html files, although that can be changed.If you wish, you can make one .php file, and include other .php files in it, if you have a lot. E.g. <html><head><title>Test Page</title></head><body><p>There's some included scripts below this!</p><?php include("[b]script.php[/b]"); ?></body></html>Replacing script.php with the filename of your .php file. Share this post Link to post Share on other sites
khaibar 0 Report post Posted June 20, 2007 Thanks a lot guys Share this post Link to post Share on other sites
MediYama 0 Report post Posted June 20, 2007 I would like to learn PHP to use it for my website, make it look fancy. But it seems to be really hard for me. Maybe I need to learn HTML a bit better... Would make a difference heh. Share this post Link to post Share on other sites
lonelym 0 Report post Posted June 21, 2007 Maybe your server/host doesn't allow the <?php ?> ending. I'm not sure, but I remember being taught that it is in one of the .INI files of PHP. Share this post Link to post Share on other sites
FirefoxRocks 0 Report post Posted June 21, 2007 That is necessary for every HTML document that you have. the xml:lang and lang things in the <html> element just declares the document to be English, so those are optional. However, the simplest format are either: Â It is part of the HTML/XHTML standards and absolutely cannot be ignored, PHP or not. Â I would like to learn PHP to use it for my website, make it look fancy. But it seems to be really hard for me. Maybe I need to learn HTML a bit better... Would make a difference heh. Yes, I recommend having an average knowledge of XHTML before integrating PHP. Seems a lot easier Maybe your server/host doesn't allow the <?php ?> ending. I'm not sure, but I remember being taught that it is in one of the .INI files of PHP. Xisto's servers are PHP and MySQL compatible. Unless you are on a non-PHP host, you should be able to execute PHP commands successfully. Share this post Link to post Share on other sites
TavoxPeru 0 Report post Posted June 22, 2007 Maybe your server/host doesn't allow the <?php ?> ending. I'm not sure, but I remember being taught that it is in one of the .INI files of PHP.No, it is not a configuration variable of the php.ini file, the configuration variable that you can set is short_open_tag and the suggested setting of this variable is to always set this to Off and in your php files always use <?php. if you turn off this variable you cant be able to use the short tag <? and if your turn On you can be able to use both, <? and <?php.  Best regards, Share this post Link to post Share on other sites
SilverFox1405241541 0 Report post Posted June 22, 2007 I own an online text based game. Good luck, I hope it works.Download WAMP5 (google it to find it) and dev it locally I recommend for one. Using this you can build your project on your local PC, which is faster and more secure. It comes with SQL, Apache, PHP5 and PHPmyadmin and runs from your taskbar.You do not need a doc type. Simply echo PHHP.<?phpecho "<html><head>..etc";?> Share this post Link to post Share on other sites
FirefoxRocks 0 Report post Posted June 23, 2007 I own an online text based game. Good luck, I hope it works.Download WAMP5 (google it to find it) and dev it locally I recommend for one. Using this you can build your project on your local PC, which is faster and more secure. It comes with SQL, Apache, PHP5 and PHPmyadmin and runs from your taskbar.You do not need a doc type. Simply echo PHHP.<?phpecho "<html><head>..etc";?> Without a doctype, it will work. But do you seriously want pages to be invalid? No, of course not! We use a doctype to follow the HTML/XHTML standards (rules). Share this post Link to post Share on other sites
TavoxPeru 0 Report post Posted June 25, 2007 Without a doctype, it will work. But do you seriously want pages to be invalid? No, of course not! We use a doctype to follow the HTML/XHTML standards (rules). That's absolutely correct. Share this post Link to post Share on other sites
iGuest 3 Report post Posted June 25, 2007 And a correct Doctype forces a Browser out of Quirks mode into a Standard Compliant mode, so use that Doctype is recommended for that reason.Otherwise, the Browser will 'guess' at the rendering of the page. Share this post Link to post Share on other sites
TavoxPeru 0 Report post Posted June 27, 2007 Searching for other stuff here at the PHP forum i found this topic that i think will help you: Introduction to PHPBest regards, Share this post Link to post Share on other sites