Jump to content
xisto Community
khaibar

Scripts And Html

Recommended Posts

Hey :P,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

Hey :P,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:
<?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

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

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

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

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

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

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

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";
?>


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

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. :P

Share this post


Link to post
Share on other sites

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.