public function downloadImage($post_id) {
$post = Post::find($post_id);
$file = public_path()."/uploads/Koala.jpg";
$headers = array('Content-Type' => ' image/jpeg');
return Response::download($file,'Koala.jpg',$headers);
}
If I remove the first line of the function it works.
The only way I found to fix this issue was to modify the code this way:
public function downloadImage($post_id) {
$post = Post::find($post_id);
$file = public_path()."/uploads/Koala.jpg";
$headers = array('Content-Type' => ' image/jpeg');
$response = Response::download($file,'Koala.jpg',$headers);
ob_end_clean();
return $response;
}
else
statement because the float
numbers are differentif (strval(0.000000000035436064) == strval(0.000000000035436064000001)) {
echo 'if';
} else {
echo 'else';
}
But if we add one 0
in front of the last digit of the second number, then if
statement will be executedif (strval(0.000000000035436064) == strval(0.0000000000354360640000001)) {
echo 'if';
} else {
echo 'else';
}
Note: The above code is one of the best solutions to compare float numbers
SELECT
table_name AS `Table`,
round(((data_length + index_length) / 1024 / 1024), 2) AS MB_size
FROM information_schema.TABLES
WHERE table_schema = "database_name"
order by MB_size desc
var arr = [55, 44, 65,1,2,3,3,34,5];
var unique = [...new Set(arr)]
$str_time = "23:12:95";
$str_time = preg_replace("/^([\d]{1,2})\:([\d]{2})$/", "00:$1:$2", $str_time);
sscanf($str_time, "%d:%d:%d", $hours, $minutes, $seconds);
$time_seconds = $hours * 3600 + $minutes * 60 + $seconds;
And if you don't want to use regular expressions:
$str_time = "2:50";
sscanf($str_time, "%d:%d:%d", $hours, $minutes, $seconds);
$time_seconds = isset($seconds) ? $hours * 3600 + $minutes * 60 + $seconds : $hours * 60 + $minutes;