Making code appear on a website?

  • Pbpixels
  • Novice
  • Novice
  • User avatar
  • Posts: 17

Post 3+ Months Ago

Hallo, I need some code to be printed on a website once pressed a button.
But I can't write something like this:
PHP Code: [ Select ]
echo '//Let us ensure that you only make between 1 to 10 fields.
   if (($fields > 0) && ($fields <= 10)) {
   echo "<h3>Your form has been created, please customise it for your needs.</h3>";
}
   else {
   echo "<h2>You can make between 1 to 10 fields.</h2>";
}'
  1. echo '//Let us ensure that you only make between 1 to 10 fields.
  2.    if (($fields > 0) && ($fields <= 10)) {
  3.    echo "<h3>Your form has been created, please customise it for your needs.</h3>";
  4. }
  5.    else {
  6.    echo "<h2>You can make between 1 to 10 fields.</h2>";
  7. }'

Since the PHP are reading the code as it should instead of printing the exact text.
Any ideas how I can make this work?
  • mindfullsilence
  • Professor
  • Professor
  • User avatar
  • Posts: 854

Post 3+ Months Ago

simply use html instead of php and wrap it in a code and pre tag:
Code: [ Select ]
<pre><code>
//Let us ensure that you only make between 1 to 10 fields.
  if (($fields > 0) && ($fields <= 10)) {
  echo "<h3>Your form has been created, please customise it for your needs.</h3>";
}
  else {
  echo "<h2>You can make between 1 to 10 fields.</h2>";
}
</code></pre>
  1. <pre><code>
  2. //Let us ensure that you only make between 1 to 10 fields.
  3.   if (($fields > 0) && ($fields <= 10)) {
  4.   echo "<h3>Your form has been created, please customise it for your needs.</h3>";
  5. }
  6.   else {
  7.   echo "<h2>You can make between 1 to 10 fields.</h2>";
  8. }
  9. </code></pre>


If it's within a control structure, then use the colon syntax:
Code: [ Select ]
<?php if ($high > $low) : ?>

<pre><code>
//Let us ensure that you only make between 1 to 10 fields.
  if (($fields > 0) && ($fields <= 10)) {
  echo "<h3>Your form has been created, please customise it for your needs.</h3>";
}
  else {
  echo "<h2>You can make between 1 to 10 fields.</h2>";
}
</code></pre>

<?php endif; ?>
  1. <?php if ($high > $low) : ?>
  2. <pre><code>
  3. //Let us ensure that you only make between 1 to 10 fields.
  4.   if (($fields > 0) && ($fields <= 10)) {
  5.   echo "<h3>Your form has been created, please customise it for your needs.</h3>";
  6. }
  7.   else {
  8.   echo "<h2>You can make between 1 to 10 fields.</h2>";
  9. }
  10. </code></pre>
  11. <?php endif; ?>

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 44 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.