• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Php echos and html

Explorer ,
Dec 31, 2009 Dec 31, 2009

Copy link to clipboard

Copied

Hi

I am designing a website and using html and php. The problem is I want to add html into my php.

The code looks like this.

<?Php

echo"<font size="2" face="Times"> try later </font>";

?>

I keep getting an error . It seems not to work. How can I manipulate the echoed text in php code?

Hope you can help.

TOPICS
Server side applications

Views

869

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jan 03, 2010 Jan 03, 2010

Marking this thread as assumed answered.

Votes

Translate

Translate
LEGEND ,
Dec 31, 2009 Dec 31, 2009

Copy link to clipboard

Copied

Hi

The problem is probably that php is confused by all the " (quotes), in the string, you can either escape the quotes of use the heredoc syntax.

See - http://uk2.php.net/manual/en/language.types.string.php.

PZ

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 31, 2009 Dec 31, 2009

Copy link to clipboard

Copied

The page is pretty help but all I want to do is change the font size and design using html when my string is echoed.

I tried using the html syntaxt in the echo but errors are showing up.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 31, 2009 Dec 31, 2009

Copy link to clipboard

Copied

Hi

Insert your echo statement inside a span and use css to format the results, e.g.

<span class="formatecho"><?PHP echo $r['item_id']?></span>

css -

.formatspan {

  color: #000;
  font-size: 1.25em;
  font-weight: bold;
  line-height: 14px;
  padding-bottom: 2px;
}

PZ

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 31, 2009 Dec 31, 2009

Copy link to clipboard

Copied

Moved to the Dreamweaver Application Development forum, which deals with PHP and other server-side issues.

Since the line in question doesn't contain any variables, it doesn't even need to be in a PHP echo statement. One of the basic attractions of PHP is that it can be embedded in HTML to display dynamic values. So, only the dynamic values need to be in echo statements.

However, the simple answer to the original question is that you can't nest the same type of quotes inside each other. Use a mixture of single and double quotes like this:

<?php echo '<font size="2" face="Times"> try later </font>'; ?>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 02, 2010 Jan 02, 2010

Copy link to clipboard

Copied

Hi thank you for the help. It worked for the echo.



I am trying to do the same thing with a or die method in my site.

The code looks like this :   or die("<font color='#333333' Size='2'> you a logged in</font>");

When I test the code nothing appears. but without the font modification the information appears.

Could any one help me.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 02, 2010 Jan 02, 2010

Copy link to clipboard

Copied

On its own, the following code works:

die("<font color='#333333' Size='2'> you a logged in</font>");

Without knowing the context the code is being used in, it's impossible to say why nothing appears.

or die() is used as a condition to end the script if something fails. There must be a condition before the "or".

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 03, 2010 Jan 03, 2010

Copy link to clipboard

Copied

the or die was for a script close on a database query.

I now just changed  in to a echo instead.

Thank you for the help.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 03, 2010 Jan 03, 2010

Copy link to clipboard

Copied

LATEST

Marking this thread as assumed answered.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines