Jump to content

Echoing long HTML strings


xtraCode

Recommended Posts

Greetings!

 

      The php script is anomalously ending with the following example.  The follow is outputted:    '; ?>

I am having a tough time finding anything wrong with my PHP script regarding HTML output.

Essentially I would like to echo the entire content of HTML found in this snip. References and resources would be excellent.

 

 

 

<html>

<head>

</head>

<body>

<div id="gallery">

<a href="#" class="show">

 

<?php

echo '<img src="starbattle1.jpg" width="100%" height="200"></a>';

?>

 

<div class="caption"><div class="content"></div></div>

</div>

<div class="clear"></div>

 

</body>

</html>

 

update, the image file path will be read in from an array.

 

 

Link to comment
Share on other sites

It appears I got the wrong end of the stick.

 

What you have just typed will work as is.

 

I will elaborate. If you have an if statement here:

 

$id = $_GET['id']; //get the id from the url

Then you can end the php tags and use normal html within the if statements:

$id = $_GET['id'];
if ($id == 1) { ?>
The ID is one, hurray!
<?php } else if ($id == 2) { ?>
Now it's two.
<?php } else { ?>
Now it's more than 2! Rebel.
<?php } ?>

Link to comment
Share on other sites

This makes sense. Trying what you suggested has not worked.

Inspecting the page source revealed this:

 

 

<div id="gallery">

<a href="#" class="show">

 

</a>';

?>

 

<div class="caption"><div class="content"></div></div>

</div>

 

 

 

You should know the elements in question belong to a Java Script image scroller.

The script is not active in this example though, so I am still left confused.

 

 

 

Link to comment
Share on other sites

Here is the updated code. Below is the page source. The php script highlight stops directly before </a>.

 

 

<html>

<head>

</head>

<body>

 

<div id="gallery">

<a href="#" class="show">

 

<?php

 

echo '<img src="starbattle.jpg" width="100%" height="200"></a>';

 

?>

 

<div class="caption"><div class="content"></div></div>

</div>

<div class="clear"></div>

 

</body>

</html>

 

 

----------------------- PAGE SOURCE ----------------------------

 

 

<html>

<head>

</head>

<body>

 

<div id="gallery">

<a href="#" class="show">

 

<?php

 

echo '<img src="starbattle.jpg" width="100%" height="200"></a>';

 

?>

 

<div class="caption"><div class="content"></div></div>

</div>

<div class="clear"></div>

 

 

 

</body>

</html>

 

 

Link to comment
Share on other sites

Make sure that

- Your file is named .php (unless you have specifically set up something else)

- PHP is installed for whatever medium (eg, Apache/IIS module or CGI)

 

I used XAMPP and I am using Apache.

The file is indeed a .php file.

 

<?php
echo 'code tag test';
?>

 

I would think some 3rd party has messed with some PHP settings, but none of my other scripts are having this issue.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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.