Jump to content
xisto Community
Sign in to follow this  
iGuest

html in php

Recommended Posts

Hi,2 things,1) I"m looking for anice begginers tut for php... please.2) How to insert an html tag in to php file? something like <br>, and so on...Thanks, and sorry for my english... :S

Share this post


Link to post
Share on other sites

to insert html into it either do<? php here?>html here - between the close tags of php<?php here?>or<?print 'html here';?>and check out the tutorial section...

Share this post


Link to post
Share on other sites

Yeah you can just exit and enter PHP mode in a PHP file as many times as you want!

 

To enter PHP mode type

 

<?php

 

to exit PHP mode type

 

?>

 

All PHP coding goes between the two php tags like so:

 

<?php

echo "hello world"!;

?>

 

Also to instert html tags into php just do sommit like:

 

<?php

echo "<a href="https://www.google.de/?gfe_rd=cr&ei=7AkjVIatDsKH8QfNkoC4DQ&gws_rd=ssl">Google!</a>";

?>

 

If you have any double quotes withing double quotes as shown above you'll need to escape the double quotes by using a in front of the double quotes.

 

Here are some additional links for PHP

 

http://php.net/

http://www.w3schools.com/

https://www.sitepoint.com/

http://www.phpfreaks.com/

Share this post


Link to post
Share on other sites

<?php

 echo "<a href="https://www.google.de/?gfe_rd=cr&ei=7AkjVIatDsKH8QfNkoC4DQ&gws_rd=ssl">Google!</a>";

?>

 

If you have any double quotes withing double quotes as shown above you'll need to escape the double quotes by using a  in front of the double quotes.

 

 

or you can just put them in single quotes.

 

<?php

echo '<a href="https://www.google.de/?gfe_rd=cr&ei=7AkjVIatDsKH8QfNkoC4DQ&gws_rd=ssl">Google!</a>';

?>

 

if you want to put php variables in the middle of a print line then you can in any of these ways...

 

<?php

echo '<br />'.$a.'<br />';

echo "<br />".$a."<br />";

echo '<br />$a<br />';

?>

Share this post


Link to post
Share on other sites
<?php  echo '<br />'.$a.'<br />';?>

This will be the fastest way, because PHP won't be searching for variables and escape characters as it would be if double quotes are used

I'm using double quotes to output only escape characters(like "n")

Share this post


Link to post
Share on other sites

There no real difference between a single or a double quote! I always use double quotes and escape double qyoutes with in double quotes! I'm not lazzy! Also with doubles you don't need do what you do above as you can just do

<?php  echo "<br />$a<br />";?>

Well poeple have different methods of using PHP! lol!

Share this post


Link to post
Share on other sites

There is a difference between single and double quotes. Strings inside single quotes are not run through for escaped characters or variables-they are simply printed. Strings inside double quotes are. As a result, the parsing of single-quoted strings is much faster than the parsing of double-quoted strings, especially if the string contains a bunch of variables and/or escaped characters. In a small script, the difference is not noticable. However, if you are designing a large application, then you should ALWAYS use single quotes for a string that does not contain an escaped character or a variable. It may also be worth it to use single quotes for everything but escaped characters, and put variables outside the quotes, like in karliks example above.

Share this post


Link to post
Share on other sites

I heard And read something about the tag or function

<?phpHTML_BLOCK>>here the HTML.<<END_HTML?>
But how does this works exactly.. :oops:

Share this post


Link to post
Share on other sites

hmm i dont know about that specific way - id be interested to know though.i use html inside php in a similar way for my form templates.<?$varname <<<HTMLhtml hereHTML;?><?print $varname;?>

Share this post


Link to post
Share on other sites

you can put html in echo butwith " you have to put echo" <img src="http://forums.xisto.com/no_longer_exists/404.png" width="10">";and with ' you can use echo" <img src='http://forums.xisto.com/no_longer_exists/404.png' width='10'>";you like ' or " ?!

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
Sign in to follow this  

×
×
  • 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.