Jump to content

I have a variable. How do i parse its contents?


zbrahead

Recommended Posts

You can't execute PHP code that way (if that's what you are after).

For pulling something out of a string (maybe the url, in this case?), there's lots of useful functions for example preg_match() and strstr()

Good question is, why would you have something like that in a variable...
If that is the code in your mysql database then you'll want use eval in order run the PHP code that is stored in your database.

for example when you get it out of your database you'll want to do something like this:

[code=php:0]eval("$your_var = \"$row['column_name_here']\";");[/code]
Either enclose the string in single quotes or escape the inner double quotes, then echo it using htmlentities()

[code]
<?php
$randomvariable = '<?php header("location:Http:somesite.com");exit;?>';
echo htmlentities($randomvariable);
?>
[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.