Reputation: 39
Basically what i mean is i want to echo a piece of a php using a php method code below is getting errors
<?php
$myString = '<?= $_GET['content'] ?>';
echo $myString;
?>
maybe theres a javascript alternative?
full code below
<?php
if (in_array($_GET['content'], array(tree, 3, 4, 5)) ) {
$myString = "<?= $_GET['content'] ?>";
$myParsedString = htmlentities($myString);
echo $myParsedString;
}
else {
echo "nothing to see here";
}
?>
Upvotes: 0
Views: 83
Reputation: 12039
No need to use another PHP tag inside PHP tag. Simply can try this
<?php
if (in_array($_GET['content'], array('tree', 3, 4, 5)) ) {
$myString = $_GET['content'];
$myParsedString = htmlentities($myString);
echo $myParsedString;
}else {
echo "nothing to see here";
}
?>
Upvotes: 0
Reputation: 11859
you can directly access $_GET
inside <?php ?>
no need to use tag again inside :try this.
$myString = $_GET['content'];
Upvotes: 2
Reputation: 10827
Just escape the PHP code you get and then u can echo it
$myString = mysql_real_escape_string('<?= $_GET['content'] ?>');
echo $myString;
I hope that helps
Upvotes: -1
Reputation: 59681
This should work for you:
if ( in_array($_GET['content'], array("tree", 3, 4, 5)) ) {
$myString = $_GET['content'];
echo $myParsedString = htmlentities($myString);
} else {
echo "nothing to see here";
}
Upvotes: 1