Free Web Hosting Forum
(#1 (permalink))
Old
Junior Member
werts15 is on a distinguished road
 
Posts: 1
Join Date: Jun 2012
Post How to put PHP into your website - 06-08-2012, 10:23 PM

I'm new, and I made a website with the website builder, but I cannot figure out how to put PHP into the website. I tried putting it in the HTML part, but it messed up. Can someone please explain how to put PHP into my website? Thanks in advance.
Reply With Quote
Sponsored Links
(#2 (permalink))
Old
Senior Member
jpardo is on a distinguished road
 
Posts: 892
Join Date: Aug 2009
Default 06-09-2012, 12:51 AM

I once try inserting php code, but you can not directly. the only way that I was using iframe. iframe you can call a php file.

to insert the iframe html code you need to create a post and editing options you add the iframe code.

regards
Reply With Quote
(#3 (permalink))
Old
bdistler's Avatar
Member
bdistler is on a distinguished road
 
Posts: 59
Join Date: Jan 2011
Location: Arizona, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Default 06-10-2012, 04:00 PM

Here is a test script that works in my accounts

copy the code below - with copy/paste into a file
be sure to end your file name with [ .php ]
put the file in you site's [ public_html ] folder
then in your Web browser enter
[ yousitedomain/yourfilename.php ]

PHP Code:
<?php error_reporting(E_ALL); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">

    <title>
      Test Hello World
    </title>
  </head>
<body>

<?php print '<h1>Hello World</h1>'?>

<br><br>

<?php
print "PHP version ==> " phpversion() . "<br><br>\n";
print 
"Server date and time is ==> " date("D M j,Y H:i:s T e",time()) . "<br>\n";
?>

</body>
</html>


Murphy's Eighth Law: If everything seems to be going well, you have obviously overlooked something.
Reply With Quote
(#4 (permalink))
Old
Junior Member
dsrdakota is on a distinguished road
 
Posts: 2
Join Date: Jun 2012
Default Hope it helps - 06-17-2012, 04:32 AM

PHP source code must be in PHP Tags:
PHP Code:
<?

?>
and HTML source can't be inside unless in `echo` functions ex:
echo "<br />";
HTML can go above or below PHP Tags.
Hope it helps;
Reply With Quote
(#5 (permalink))
Old
dx4's Avatar
dx4 dx4 is offline
Member
dx4 is on a distinguished road
 
Posts: 95
Join Date: Mar 2012
Send a message via Skype™ to dx4
Default 06-17-2012, 09:26 AM

Also, in case you don't know, be careful with ".

Ex: If you want to write

<input type="text" .....

You should write it (inside the php code) :

echo "<input type=\"text\" ....

So the " are not messed up.


And when everything else fail, try reading the manual.

Last edited by dx4; 06-17-2012 at 09:28 AM.
Reply With Quote
(#6 (permalink))
Old
bdistler's Avatar
Member
bdistler is on a distinguished road
 
Posts: 59
Join Date: Jan 2011
Location: Arizona, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Default 06-17-2012, 01:08 PM

Quote:
Originally Posted by dsrdakota View Post
PHP source code must be in PHP Tags:
PHP Code:
<?

?>
When PHP parses a file, it looks for opening and closing tags, which are <?php and ?>

PHP also allows for short tags <? and ?> (which are discouraged because they are only available if enabled with short_open_tag php.ini configuration file directive, or if PHP was configured with the --enable-short-tags option

==============================
Quote:
Originally Posted by dsrdakota View Post
and HTML source can't be inside unless in `echo` functions ex:
echo "<br />";
while you did not ask how to put HTML code inside PHP code
here is one way to put a whole HTML page inside PHP code

PHP Code:
<?php
print <<<here
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">

    <title>
      Test Hello World
    </title>
  </head>
<body>

<h1>Hello World</h1>'

</body>
</html>
here;
?>
==============================
Quote:
Originally Posted by dsrdakota View Post
HTML can go above or below PHP Tags.
You can mix HTML and PHP code as much as you like in your source file


Murphy's Eighth Law: If everything seems to be going well, you have obviously overlooked something.
Reply With Quote
(#7 (permalink))
Old
bdistler's Avatar
Member
bdistler is on a distinguished road
 
Posts: 59
Join Date: Jan 2011
Location: Arizona, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Default 06-17-2012, 01:47 PM

Quote:
Originally Posted by dx4 View Post
Also, in case you don't know, be careful with ".

Ex: If you want to write

<input type="text" .....

You should write it (inside the php code) :

echo "<input type=\"text\" ....

So the " are not messed up.
Here is a PHP source file that prints its own source code on a web page
there is more to printing source code on a web page than ==> \" <==

you can see the web page - made with this code - here

http://realhandydata.info/hello_world.php

PHP Code:
<?php error_reporting(E_ALL); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">

    <title>
      Test Hello World
    </title>
  </head>
<body>

<?php print '<h1>Hello World</h1>'?>

<br><br>

<?php
print "PHP version ==> " phpversion() . "<br><br>\n";
print 
"Server date and time is ==> " date("D M j,Y H:i:s T e",time()) . "<br>\n";
?>

<br><br>

<pre>

##########################################################
### to get the above output from your site             ###
### copy the code below - with copy/paste into a file  ###
### be sure to end your file name with [ .php ]        ###
### put the file in you site's [ public_html ] folder  ###
### then in your Web browser enter                     ###
### [ yousitedomain/yourfilename.php ]                 ###
##########################################################

------ copy below this line - no blank line on top -------
&lt;?php error_reporting(E_ALL); ?&gt;
&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;&gt;
&lt;html&gt;
  &lt;head&gt;
    &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=ISO-8859-1&quot;&gt;

    &lt;title&gt;
      Test Hello World
    &lt;/title&gt;
  &lt;/head&gt;
&lt;body&gt;

&lt;?php print '&lt;h1&gt;Hello World&lt;/h1&gt;'; ?&gt;

&lt;br&gt;&lt;br&gt;

&lt;?php
print &quot;PHP version ==&gt; &quot; . phpversion() . &quot;&lt;br&gt;&lt;br&gt;\n&quot;;
print &quot;Server date and time is ==&gt; &quot; . date(&quot;D M j,Y H:i:s T e&quot;,time()) . &quot;&lt;br&gt;\n&quot;;
?&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>

</body>
</html>


Murphy's Eighth Law: If everything seems to be going well, you have obviously overlooked something.
Reply With Quote
Reply

Tags
php

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.5.2
vBulletin Skin developed by: vBStyles.com