Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Web Coding › PHP: Bold letters and Line Break in echo
New Posts  All Forums:Forum Nav:

PHP: Bold letters and Line Break in echo

post #1 of 4
Thread Starter 
I am beginner to PHP and have a quick question regarding the following code:
Code:
<?php
        $array = array("name"=>"Toyota","type"=>"Celica","colour"=>"black","manufactured"=>"1991");
        $array2 = array("Toyota","Celica","black","1991");
        $array3 = array("name"=>"Toyota","Celica","colour"=>"black","1991");

        echo "Manufacturer: &lt;b&gt;{$array['name']}&lt;/b&gt;&lt;br /&gt;\n";
        echo "Brand: &lt;b&gt;{$array2['1']}&lt;/b&gt;&lt;br /&gt;\n";
        echo "Colour: &lt;b&gt;".$array3['colour']."&lt;/b&gt;&lt;br /&gt;\n";
        echo "Year Manufactured: &lt;b&gt;".$array3[1]."&lt;/b&gt;&lt;br /&gt;\n";
?>

Why does firefox render the above code the following way:
Code:
Manufacturer: <b>Toyota</b><br /> Brand: <b>Celica</b><br /> Colour: <b>black</b><br /> Year Manufactured: <b>1991</b><br /> 

Rather than making the words bold and applying line breaks? Thanks for the help.
Hades
(13 items)
 
  
CPUMotherboardGraphicsRAM
Core 2 Duo E8400 @ 4.0GHz Abit IP35 Pro GeForce 8800 GTS 320Mb Mushkin 2 x 1GB 996523 
Hard DriveOptical DriveOSMonitor
2 x 500GB Samsung Spinpoint F1-Raid 0 + 1 x 250GB 1 x DVD/CD Drive + 1 x DVDRW Drive Windows 7 Ultimate 64 Bit LG L206WTY-BF 
KeyboardPowerCaseMouse
Saitek Eclipse II PC Power & Cooling TURBO-COOL 850 SSI Cooler Master Cosmos 1010 ESA Razer Deathadder 
Mouse Pad
SteelPad 5L Precision 
  hide details  
Reply
Hades
(13 items)
 
  
CPUMotherboardGraphicsRAM
Core 2 Duo E8400 @ 4.0GHz Abit IP35 Pro GeForce 8800 GTS 320Mb Mushkin 2 x 1GB 996523 
Hard DriveOptical DriveOSMonitor
2 x 500GB Samsung Spinpoint F1-Raid 0 + 1 x 250GB 1 x DVD/CD Drive + 1 x DVDRW Drive Windows 7 Ultimate 64 Bit LG L206WTY-BF 
KeyboardPowerCaseMouse
Saitek Eclipse II PC Power & Cooling TURBO-COOL 850 SSI Cooler Master Cosmos 1010 ESA Razer Deathadder 
Mouse Pad
SteelPad 5L Precision 
  hide details  
Reply
post #2 of 4
use actual < > not html entities.
Code:
&lt; &gt;
that should fix your problem.

example:
Code:
echo "<".$string.">";

but to explain basically you would use html entities to show code rather than generate code.

http://www.w3schools.com/html/html_entities.asp
Edited by thenk83 - 2/2/12 at 6:26pm
Ol' Betsy (Main)
(16 items)
 
 
CPUMotherboardGraphicsRAM
AMD FX-8150 Gigabyte GA-78LMT-USB3 ATI Radeon HD 3000 G.Skill Value Series 4GB (x4) 
Hard DriveCoolingOSMonitor
Western Digital Red 2TB (x4) Cooler Master GeminII S524 VMWare ESXi 5.1 Asus VS238H-P 
KeyboardPowerCaseMouse
Ducky Shine White LED Corsair CX500 Lian Li PC-A04B Logitech G9  
AudioOtherOther
Realtek ALC887 Adaptec RAID 6405 Intel Gigabit CT NIC 
  hide details  
Reply
Ol' Betsy (Main)
(16 items)
 
 
CPUMotherboardGraphicsRAM
AMD FX-8150 Gigabyte GA-78LMT-USB3 ATI Radeon HD 3000 G.Skill Value Series 4GB (x4) 
Hard DriveCoolingOSMonitor
Western Digital Red 2TB (x4) Cooler Master GeminII S524 VMWare ESXi 5.1 Asus VS238H-P 
KeyboardPowerCaseMouse
Ducky Shine White LED Corsair CX500 Lian Li PC-A04B Logitech G9  
AudioOtherOther
Realtek ALC887 Adaptec RAID 6405 Intel Gigabit CT NIC 
  hide details  
Reply
post #3 of 4
Code:
<?php
        $array = array("name"=>"Toyota","type"=>"Celica","colour"=>"black","manufactured"=>"1991");
        $array2 = array("Toyota","Celica","black","1991");
        $array3 = array("name"=>"Toyota","Celica","colour"=>"black","1991");

        echo "Manufacturer: <b>{$array['name']}</b><br />\n";
        echo "Brand: <b>{$array2['1']}</b><br />\n";
        echo "Colour: <b>".$array3['colour']."</b><br />\n";
        echo "Year Manufactured: <b>".$array3[1]."</b><br />\n";
?>
Ol' Betsy (Main)
(16 items)
 
 
CPUMotherboardGraphicsRAM
AMD FX-8150 Gigabyte GA-78LMT-USB3 ATI Radeon HD 3000 G.Skill Value Series 4GB (x4) 
Hard DriveCoolingOSMonitor
Western Digital Red 2TB (x4) Cooler Master GeminII S524 VMWare ESXi 5.1 Asus VS238H-P 
KeyboardPowerCaseMouse
Ducky Shine White LED Corsair CX500 Lian Li PC-A04B Logitech G9  
AudioOtherOther
Realtek ALC887 Adaptec RAID 6405 Intel Gigabit CT NIC 
  hide details  
Reply
Ol' Betsy (Main)
(16 items)
 
 
CPUMotherboardGraphicsRAM
AMD FX-8150 Gigabyte GA-78LMT-USB3 ATI Radeon HD 3000 G.Skill Value Series 4GB (x4) 
Hard DriveCoolingOSMonitor
Western Digital Red 2TB (x4) Cooler Master GeminII S524 VMWare ESXi 5.1 Asus VS238H-P 
KeyboardPowerCaseMouse
Ducky Shine White LED Corsair CX500 Lian Li PC-A04B Logitech G9  
AudioOtherOther
Realtek ALC887 Adaptec RAID 6405 Intel Gigabit CT NIC 
  hide details  
Reply
post #4 of 4
Thread Starter 
Thanks for the help, it worked.
Hades
(13 items)
 
  
CPUMotherboardGraphicsRAM
Core 2 Duo E8400 @ 4.0GHz Abit IP35 Pro GeForce 8800 GTS 320Mb Mushkin 2 x 1GB 996523 
Hard DriveOptical DriveOSMonitor
2 x 500GB Samsung Spinpoint F1-Raid 0 + 1 x 250GB 1 x DVD/CD Drive + 1 x DVDRW Drive Windows 7 Ultimate 64 Bit LG L206WTY-BF 
KeyboardPowerCaseMouse
Saitek Eclipse II PC Power & Cooling TURBO-COOL 850 SSI Cooler Master Cosmos 1010 ESA Razer Deathadder 
Mouse Pad
SteelPad 5L Precision 
  hide details  
Reply
Hades
(13 items)
 
  
CPUMotherboardGraphicsRAM
Core 2 Duo E8400 @ 4.0GHz Abit IP35 Pro GeForce 8800 GTS 320Mb Mushkin 2 x 1GB 996523 
Hard DriveOptical DriveOSMonitor
2 x 500GB Samsung Spinpoint F1-Raid 0 + 1 x 250GB 1 x DVD/CD Drive + 1 x DVDRW Drive Windows 7 Ultimate 64 Bit LG L206WTY-BF 
KeyboardPowerCaseMouse
Saitek Eclipse II PC Power & Cooling TURBO-COOL 850 SSI Cooler Master Cosmos 1010 ESA Razer Deathadder 
Mouse Pad
SteelPad 5L Precision 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Web Coding
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Web Coding › PHP: Bold letters and Line Break in echo