|
|
|
|
![]() ![]() |
Jun 19 2007, 05:53 PM
Post
#1
|
|
|
Newbie [ Level 1 ] Group: Members Posts: 8 Joined: 19-June 07 Member No.: 22,771 |
Hey
In the note pad, I put the proper code for php <?php ?> and save the file as name.php But 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 |
|
|
|
Jun 19 2007, 10:11 PM
Post
#2
|
|
|
Super Member Group: [HOSTED] Posts: 713 Joined: 8-April 06 From: Lima - Peru Member No.: 12,579 |
Hey In the note pad, I put the proper code for php <?php ?> and save the file as name.php But 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: CODE <?php // simple example ?> <html> <head> <?php echo "<title>Simple Example</title>\n"; ?> </head> <?php echo "<body style=\"margin:0 auto;color:#900;\">\n" . "<p>Simple Example<br />Other texts....</p>\n"; ?> </body> </html> Best regards, |
|
|
|
Jun 20 2007, 04:23 AM
Post
#3
|
|
|
Super Member Group: [HOSTED] Posts: 589 Joined: 12-July 06 From: Ontario, Canada Member No.: 14,464 |
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: CODE <?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="http://www.w3.org/1999/xhtml"> <head> <title>My 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. |
|
|
|
Jun 20 2007, 06:06 AM
Post
#4
|
|
|
Premium Member Group: [HOSTED] Posts: 255 Joined: 17-June 07 From: Tasmania Member No.: 22,699 |
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. CODE <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. |
|
|
|
Jun 20 2007, 12:14 PM
Post
#5
|
|
|
Newbie [ Level 1 ] Group: Members Posts: 8 Joined: 19-June 07 Member No.: 22,771 |
Thanks a lot guys
<quote> <!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="http://www.w3.org/1999/xhtml"> </quote> Is that necessary O_o? |
|
|
|
Jun 20 2007, 06:14 PM
Post
#6
|
|
|
Member - Active Contributor Group: Members Posts: 93 Joined: 11-June 07 Member No.: 22,564 |
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.
|
|
|
|
Jun 21 2007, 10:53 AM
Post
#7
|
|
|
Member - Active Contributor Group: Members Posts: 91 Joined: 18-May 07 Member No.: 22,008 |
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.
|
|
|
|
Jun 21 2007, 12:55 PM
Post
#8
|
|
|
Super Member Group: [HOSTED] Posts: 589 Joined: 12-July 06 From: Ontario, Canada Member No.: 14,464 |
Thanks a lot guys <quote> <!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="http://www.w3.org/1999/xhtml"> </quote> Is that necessary O_o? 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: CODE <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> or stricter.... CODE <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> 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. Astahost's servers are PHP and MySQL compatible. Unless you are on a non-PHP host, you should be able to execute PHP commands successfully. |
|
|
|
Jun 22 2007, 04:08 AM
Post
#9
|
|
|
Super Member Group: [HOSTED] Posts: 713 Joined: 8-April 06 From: Lima - Peru Member No.: 12,579 |
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, |
|
|
|
Jun 22 2007, 04:49 AM
Post
#10
|
|
|
Premium Member Group: Members Posts: 206 Joined: 26-February 07 From: Texas Member No.: 20,598 |
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. <?php echo "<html><head>..etc"; ?> |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 7th July 2008 - 12:24 AM |