Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I am trying to pass some variables through url in php. Im using the following script
$query1 = new ParseQuery("Drivers");
$query1->includeKey("driverUserId");
$query1->descending("createdAt");
$results1 = $query1->find();
$object1 = $results1[$i];
$uname=$object1->get('driverUserId');
echo ''.$uname->get('name').'';
echo '<td>'.$uname->get('name').'</td>';
echo '<td>'.$uname->get('username').'</td>';
But when I execute the page, script stopped working in this line.
echo ''.$uname->get('name').'';
When I removed '.$uname.' it worked fine.
Because if $uname has a ->get() method, it's obviously a class or an object and you can't directly use it like a string (if it hasn't any tostring modifiers). Try to write it like this (just guessing):
echo ''.$uname->get('name').'';
Use the below code:
$id=$uname->get('id');
$name=$uname->get('name');
echo ''.$name.'';
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
Please can anyone help me out, I've done an API Call and I need to get a single value from the response, as response comes with jsonp.
jsonp ({"statuscode":"025","RRR":"290007816182","status":"Payment Reference generated"})"
You should get response in a variable and use json_decode function like following :
$response = '{"statuscode":"025","RRR":"290007816182","status":"Payment Reference generated"}';
$result = json_decode($response);
echo $result->statuscode;
echo "<br>";
echo $result->RRR;
echo "<br>";
echo $result->status;
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
I'm PHP developer but i cant understand this error
$uid = $this->db->Tables("telegrambots")->search([
"telegrambotid" => $this->botKey
])['uniqueId'];
if (!file_exists("TelegramBotCommands/{$uid}"))
mkdir("TelegramBotCommands/{$uid}");
Eval is evil, you probably don't need it so don't use it. You want to make a call to a class with a dynamic name? Use this:
$dynamic_class_name = 'Video';
$video = new $dynamic_class_name();
That being said, your snippet with eval seems to work perfectly fine:
http://sandbox.onlinephpfunctions.com/code/e3bb43b1ccfd27365247120e9c5751aac9e2b4ce
You would have to check your logs as to what the error is.
EDIT:
As you said you are using namespaces, try to use the full classname including the namespace in the eval function (like new \namespace\Videos(.... Even better though: don't use eval!
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
Im newbie in php im learning it since some weeks ago but i didnt understand one thing.
I have a
$url = "http://example.com/";
define('LOCATION', '<?php echo $url; ?>');
but it is not working. I didnt understand why "define" term cannot read
<?php
$url = "http://example.com/";
define('LOCATION', $url);
1.You are alreay in php tag,so no need of any extra php tag.
2.And when assigning value to a variable , we never use echo in php . Its used to display value in html only.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
Please tell me how to do a find and replace in PHP.
I nee to find Entry="OK" and replace with OK in a xml file.
I tried str_replace but confused because of the = and " in it.
Even though I'm not sure of the environment you're working in, here's a php sample that I think does what you want:
<html>
<?php
$teststr = "Entry=\"OK\"";
print $teststr . "<br>";
$newanswer = str_replace($teststr, "Entry=OK", $teststr);
print $newanswer . "<br>";
?>
</html>
Try this way
str_replace('Entry="OK"','OK',$var);
You can use str_replace its working
$r = 'Entry="OK" tyyuu hhh';
echo str_replace($r,'Entry="OK"','OK');
if any error found then u use preg_replace with corresponding patteren
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I have a variable inside an inline style -
style='color:$custom_color;font-size:$custom_icon_size;'
And am trying to add the letters px directly after the $custom_icon_size. This obviously does not work? Any ideas what is the correct method?
thanks
you need to use {} around your PHP vaariable
style='color:$custom_color;font-size:${custom_icon_size}px;'
Assuming that you're echoing it, you have two options:
echo "style='color:$custom_color;font-size:{$custom_icon_size}px;'";
echo "style='color:" . $custom_color . ";font-size:" . $custom_icon_size . "px;'";
$style = 'color:'.$custom_color.'; font-size: '.$custom_icon_size.'px';
echo 'style="'.$style.'"';