How to display HTML code as HTML code using PHP [closed] - php

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have the PHP code as below:
<?php
echo "<tr></tr>";
//ouput I want : <tr></tr>
?>
When Output I want to display <tr></tr>.But I don know whitch function that I should use for this,anyone know help me please,thanks

Try with htmlentities like
<?php
echo htmlentities("<tr></tr>");
?>
Follow this LINK

You can also make use of htmlentities()
<?php
echo htmlentities("<tr></tr>");
?>

Try this
$output = htmlspecialchars("<tr></tr>", ENT_QUOTES);

Use htmlentities
<?php
echo htmlspecialchars('<tr></tr>');
?>

Related

PHP Reading the URL [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
How do I make the following url to be read:
localhost/index.php?errormsg=wrongpassword
so I want it to set the variable $errormsg to 'wrongpassword' how do I do that? I am pretty sure there is a way using $_GET or $_POST?
You want to use $_GET['errormsg'].
Something like this should do:
if isset($_GET['errormsg'])
{
echo $_GET['errormsg'];
}
$errormsg = $_GET['errormsg']
This should do the trick for you
$_GET['errormsg'] is the answer of your question.
print_r($_GET)
to see all variables in the URL. in this case you want
$_GET['errormsg']
You were as close as ever. A single google would've yielded the answer to you :)
http://php.net/manual/en/reserved.variables.get.php
<?php
// use htmlspecialchars() to clean up url-encoded characters
$error_message = htmlspecialchars($_GET["errormsg"]);
echo 'Error: ' . $error_message;
?>
prints: "Error: error_here", if url = ...?errormsg=error_here

How to customize my php echo code? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
i echo some data in the Author Box of my Wordpress Theme with:
<?php echo $user_info->new_user_blond; ?> <?php echo $user_info->new_user_brown; ?> <?php echo $user_info->new_user_red; ?>
The users can check one ore more checkboxes. If a user checks all 3 Checkboxes for example the result shows up in the author box as:
blond brown red
Everthing works fine, but please help me to change my code to achive this result:
blond, brown, red
When i put a "," between the codes it shows me the desired result. BUT if a user
only checks on checkbox it shows me:
blond,,
I would be very pleased if you would support me :)
<?php
$userarr = array(
$user_info->new_user_blond,
$user_info->new_user_brown,
$user_info->new_user_red,
);
$result = implode(',',array_filter($userarr));
echo $result;
?>

PHP Code Session Not Working [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
My PHP code dosnt seem to be working and I dont Know Why when Ever I Use this code it will Make The whole webpage appear white.I think the problem is Here Somewhereecho Hello, (.$_SESSION['username'], ENT_QUOTES, 'UTF-8');Thanks In Advance
session_start();
if(!isset($_SESSION['user']) && empty($_SESSION['user'])) {
echo '<b>Log In</b>';
}
else {
echo Hello, (.$_SESSION['username'], ENT_QUOTES, 'UTF-8');
echo '</br></b>';
echo '<b>Log Out</b>';
}
When your page goes white, it usually means you have a fatal error in your code and need to check your logs, or turn on error_reporting.
In this case you're missing quotes, have the concatenation a bit messed up, and appear to be missing a function call (probably htmlspecialchars).
Also, you're checking $_SESSION['user'] a few lines before in your code, are you sure you don't mean to echo that here instead of $_SESSION['username']?
I think you want to change that line to:
echo "Hello, " . htmlspecialchars($_SESSION['user'], ENT_QUOTES, 'UTF-8');

PHP echo same function twice [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I need to echo a paging function twice,
echo blaetterfunktion($seite, $wieviele_seiten);
content
echo blaetterfunktion($seite, $wieviele_seiten);
I guess that would burden the server twice?
What can I do to have the server burdened just once and still echo it twice?
Place the result of the function in a variable:
<?php
$result = blaetterfunktion($seite, $wieviele_seiten);
echo $result;
?>
content
<?php
echo $result;
?>
Save it to a variable:
<?php
$variable = blaetterfunktion($seite, $wieviele_seiten);
echo $variable;
?>
content
<?php
echo $variable;
?>

Php:Return a String from a function [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
The simple program is not returning the string,Please help.
<?php
function returnStr() {
return "fooBar";
}
$str=returnStr();
echo $str;
}
?>
It's a parse error:
$str=returnStr();
echo $str;
} // WHAT IS THIS BRACKET DOING HERE?
There's a fatal error tokenizing the code due the trailing/unmatched '}' remove that and the code will work. Then spend some time thinking about why you didn't know this already
There's an error in your code. The last } is useless.

Categories