nocalis
nocalis

Reputation: 176

PHP echo plain text

I am working on an AWS Elastic Beanstalk and using php on it.

But when I try to echo some html / javascript text, it just get print me plain text !

Here's an example :

<?php 
  public function testing (){
       echo "<h1>Hello World !</h1>";
  }
?>

Gives me this.

For information I am working with an api, and my testing function is called on http://xxx.eu-west-1.elasticbeanstalk.com/test/lavachart

I really can't understand why the html / javascript code isn't interpreted.

Thanks for answers

Upvotes: 3

Views: 3376

Answers (1)

Naumov
Naumov

Reputation: 1167

<?php 
  header('Content-type:text/html; charset=UTF-8');
  public function testing (){
       echo "<h1>Hello World !</h1>";
  }
?>

for example you need response right content type for your php script, if this html then content type text/html. But you can have not right configuration server. you can just adding mime for php in you .htaccess file or virtualhost configuration

AddType text/html .php

Upvotes: 6

Related Questions