Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8984403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:05:52+00:00 2026-06-15T21:05:52+00:00

I’m attempting to create a custom 404 page in CakePHP 2.0 by extending ExceptionRenderer.

  • 0

I’m attempting to create a custom 404 page in CakePHP 2.0 by extending ExceptionRenderer. Everything is working fine except when I output HTML marked-up strings in the View Cake is unwantedly encoding the HTML entities. How can I prevent this from happening?

In my renderer I have:-

class AppExceptionRenderer extends ExceptionRenderer {
    public function missingController($error) {
        $this->controller->set('test', '<p>Test</p>');
        header('HTTP/1.1 404 Not Found');
        $this->controller->render('/Errors/error404', 'default');
        $this->controller->set('title_for_layout', 'Page Not Found');
        $this->controller->response->send();
    }
}

In the view (View/Error/error404.ctp):-

<?php echo $test ?>

This outputs &lt;test&gt; rather than <p>test</p>.

In my actual code test will be being set by content from the database as this is a CMS driven site. I’m just setting test in the renderer code above as an example (and to prove the code is behaving as I am observing).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T21:05:53+00:00Added an answer on June 15, 2026 at 9:05 pm

    You shouldn’t be using HTML inside your PHP, you should write any markup in the view file.

    I’ve not come across a situation when you would need to write the markup inside your PHP code, but if you have no other way around it you could always use the html_entity_decode() function inside your view.

    Unfortunately I don’t know a way to stop Cake from encoding it automatically like you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
Basically, what I'm trying to create is a page of div tags, each has
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
i got an object with contents of html markup in it, for example: string
I have thousands of HTML files to process using Groovy/Java and I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.