Forum     

Go Back   Digit Technology Discussion Forum > Portables, Peripherals and Electronics > QnA (read only)
Register FAQ Calendar Mark Forums Read

QnA (read only) Mods please help transfer the contents of this forum to proper sections. :)


 
 
LinkBack Thread Tools Search this Thread Display Modes
Old 18-10-2006, 08:49 PM   #1 (permalink)
Apprentice
 
gursimran_2006's Avatar
 
Join Date: Sep 2006
Location: In ur Dreams
Posts: 92
Lightbulb HTML Code in PHP


How 2 add HTML Code In PHP Webpage
__________________
Friends, Plzzz Visit my website
http://www.gursimran.c-o.in/
add ur link to my Database and signup it is Free!
Plzzz do not forget click on Advertisements, coz i need $$
Cheers,
Gursimran.
gursimran_2006 is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 18-10-2006, 09:06 PM   #2 (permalink)
String Phreak
 
mediator's Avatar
 
Join Date: Mar 2005
Location: In ur Evil Mind!
Posts: 2,457
Default Re: HTML Code in PHP

Thats easy! U have 2 options
Let me give u an example with <a href...> thing!

1. : Parting the Php block
Code:
<?php
{
//code...php block initiated
?>
<a href="mediator_is_great.htm">meds</a>
<?php
//code php block completed
}
?>
2. : In one go!
Code:
<?php
$link="mediator_is_great.html";
$name="meds";
echo "<a href=\"$link\">$name</a>";
?>
Like wise to mark something bold we have
Code:
<?php
echo "<b>mediator is cool</b>";
?>
Ur Problem Solved!
__________________
Bad Bad server.....No candy for u!

Last edited by mediator; 18-10-2006 at 09:12 PM.
mediator is offline  
Old 18-10-2006, 09:32 PM   #3 (permalink)
Alpha Geek
 
Join Date: Aug 2006
Posts: 569
Default Re: HTML Code in PHP

Just use it after any php code end (IMO), google further
Stick is offline  
Old 18-10-2006, 09:33 PM   #4 (permalink)
In Pursuit of "Happyness"
 
kalpik's Avatar
 
Join Date: May 2005
Location: New Delhi
Posts: 3,432
Default Re: HTML Code in PHP

Mediator has given the correct solution, so no need to google!
kalpik is offline  
Old 18-10-2006, 09:37 PM   #5 (permalink)
eWebGuru
 
ahref's Avatar
 
Join Date: Mar 2006
Location: Dehradun
Posts: 427
Default Re: HTML Code in PHP

Although mediator has explained clearly. Let me add my two cents
Server will treat everything outside <?php ?> tags as html.
If you want to add any html tag in php script then use eithter echo or print command like
<?php
print "<h1>Hello World</h1>";
?>
__________________
Windows and linux hosting at http://www.ewebguru.com
Get $50 per blog post PM me for details.
ahref is offline  
Old 19-10-2006, 11:34 AM   #6 (permalink)
Human Spambot
 
tuxfan's Avatar
 
Join Date: Feb 2004
Location: Mumbai
Posts: 2,653
Default Re: HTML Code in PHP

My further 1 cent in addition to ahref's 2 cents

Its not the server that treats PHP, its the PHP interpreter that does the job!! Here's the over-simplified sequence.
  1. A browser sends a request for a file to the server.
  2. If its .php file, Apache calls in PHP interpreter for help and hands over the file to it.
  3. PHP interpreter goes thru the file and processes everything thats within <?php and ?> tags. However, it doesn't do anything to the code thats outside those tags.
  4. Apache once again takes over the output give by the interpreter and hands it over to the browser which is dumb enough to understand only HTML and Javascript.
  5. If the browser is IE, it will render even a W3 standard compliant page erroneously. If the browser is not IE, it is more likely that the page is rendered correctly
I would also like to point out that PHP can be used anywhere on the page whether it be <head> or <title> or whatever!! For example, based on certain criterion, it can even me made to select a differnt external CSS files or change the title of the page. Here's a small simple example.

PHP Code:
<html>
  <head>
    <title>
      <?php
        $myid 
$_GET["identity"];
        if (
$myid == "one")
          print(
"This is the my favourite page tite");
         else
          print(
"This is the default page title");
      
?>
    </title>
  </head>
  <body>
  </body>
</html>
So start thinking a little differently. You can use break-away from static code anywhere with just the <?php and ?> tags. All that you need is .php extension to the file.
__________________
:: Free hosting and free domain names available in special cases. Conditions apply ::

Last edited by tuxfan; 19-10-2006 at 11:42 AM.
tuxfan is offline  
Old 19-10-2006, 11:37 AM   #7 (permalink)
"The Cake is a Lie!!"
 
[xubz]'s Avatar
 
Join Date: Oct 2006
Posts: 471
Default Re: HTML Code in PHP

Guys, its better if you use PHP BBCode Tag..

PHP Code:
<html>
  <body>
    <b>
    <?php
       $a
=1;
       
$b=2;
       if(
$a==$b) {
          echo 
"Bull5hit!";
       } else {
          die(
"Yay!");
       }
     
?>
     </b>
  </body>
</html>
__________________
[xubz] ● http://xubz.com/
[steam_id] ● http://steamcommunity.com/id/xubz
[xubz] is offline  
Old 19-10-2006, 11:42 AM   #8 (permalink)
Human Spambot
 
tuxfan's Avatar
 
Join Date: Feb 2004
Location: Mumbai
Posts: 2,653
Default Re: HTML Code in PHP

Quote:
Originally Posted by subbzzz
Guys, its better if you use PHP BBCode Tag..
At first, I didn't understand what you are saying! But then found out that you are right. You are talking about the php tag for posting in the forum. The tag makes the PHP code more readable on the forum and its nothing to do with the php tag in HTML pages.
__________________
:: Free hosting and free domain names available in special cases. Conditions apply ::
tuxfan is offline  
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 On
Pingbacks are On
Refbacks are On


 
Latest Threads
- by Sujeet
- by Krow
- by abhidev
- by topgear

Advertisement




All times are GMT +5.5. The time now is 07:26 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2