How to Pass BackSlash at end of string? - php

I m trying to delete one image using unlink function.
But path creates error to pass. My syntax is as below.
unlink('customer\'.$user_id."\book\".$id);
But this will generate error here.
Please help me to solve this. Thanks in advance.

Try this:
unlink('customer\\'.$user_id."\\book\\".$id);

Use this (Use Backslash)
unlink("customer/".$user_id."/book/".$id)

Related

I can't find the error in this line

I can't find the error in this line of php code.I tried checking it online and I get this is wrong. 'darth'(T_STRING), expecting ']' in your code on line 1
I am new and know very little about coding. Can someone please help! Thank you!
if(trim(strtolower($_POST['bonusq’]))!='darth vader’) {
You are using typographical single quotes after "bonusq" and "vader", which can't work - change them to regular quotes
Try with this:
$a = $_POST['bonusq'];
if(trim(strtolower($a))!='darth vader') {
Hope to help you.

PhpSpreadsheet's COUNTIF Function php

I am working with PhpSpreadsheet(PHPExcel) to do an Excel in PHP and I got stuck when I needed to use COUNTIF. Here is my code:
$spreadsheet->getActiveSheet()->setCellValueByColumnAndRow(59,5,"=COUNTIF(BH7:BH125,'<>0')"); //BH POSITION
It doesn't work. If I putt /* BH7:BH125, 0 */ ,then it works but I want to use <>0. Can anyone help me?
Thanks.
It expects double-quotes for string parameter. Instead
"=COUNTIF(BH7:BH125,'<>0')"
try to use
"=COUNTIF(BH7:BH125,\"<>0\")"

How to extract string from another string between the Nth and N+1th 'breakword' in php?

My example code is given below.
$a= "I think there are many people who can help in my difficulty. breakword Thank you in advance. brwakword If i got this solution I will be happy. Breakword I have already searched in google about it I did not get it's solution. Breakword If you have any link of solution please help me. breakword Thank you again!";
From the above string I want to get the sentence between 2nd and 3rd 'breakword' word.
It means I want to extract 'If i got this solution I will be happy.'.
If you have any solution please help me. Thank you in advance
You can split your string into smaller parts using explode() and get the "Nth" part of the array.
$sentences = explode('breakword', $a);
echo $sentences[2];
PHP > 5.4 will support this too :
echo explode('breakword', $a)[2];
a similar approach but intead of using explode you can also use preg_split
supports (PHP 4, PHP 5)
preg_split('/breakword/', $a);
for the second answer you can use
$dummy=array();
preg_match_all('/breakword/', $a,$dummy)

PHP: Use a $_GET-Param with multiple other Params within a $_GET-Param

yeah, I know, the title is kind of confusing, but no better title came to my mind.
Here is my problem:
I want to use a link in my application, which would look like this:
localhost/index?jumpto=some_folder/somescript.php?someparam1=1234&someparam2=4321
The problem is that &someparam2 is meant to hang on the second $_GET-Param.
It would be like this:
localhost/index?jumpto=some_folder/somescript.php?someparam1=1234&someparam2=4321
Instead, PHP interprets that &someparam2 hangs on the first $_GET-Param.
localhost/index?jumpto=some_folder/somescript.php?someparam1=1234&someparam2=4321
Does anyone know a solution for this?
I already tried
localhost/index?jumpto='some_folder/somescript.php?someparam1=1234&someparam2=4321'
but of course that didn't work.
I hope you can understand my problem.
Thank you for your time.
You will need to URL encode your string some_folder/somescript.php?someparam1=1234 so that php will not parse & in the query string as a param separator.
use urlencode("some_folder/somescript.php?someparam1=1234");

replace the unknown value using php

In my project am using some post, in that post i got a error in browser like this,
"fourth � one - hai" => i paste that error, but i cant get in, Its like a square between fourth and one... But i dont know that issue, and also i cant string replace that value, and i try to attach the screenshot, that also not working...
And if u want to see that symbol please inspect the space between fourth and one... Help me..
Not sure with your question but check the PHP manual.
http://in.php.net/manual/en/function.mb-split.php

Categories