Hello would like to know how can I get this syntax correct.
I got this code from: http://php.net/manual/en/function.exif-read-data.php
code below:
<?php
$exif = exif_read_data('tests/test2.jpg', 0, true);
echo "test2.jpg:<br />\n";
foreach ($exif as $key => $section) {
foreach ($section as $name => $val) {
echo "$key.$name: $val<br />\n";
}
}
?>
now I want to add a line which actualy gives you the image name. test1.jpg etcs from php array.
test/<?=$prod['image_url'] ?>
like this
<?php
$exif = exif_read_data('test/<?=$prod['image_url'] ?>', 0, true);
echo "test2.jpg:<br />\n";
foreach ($exif as $key => $section) {
foreach ($section as $name => $val) {
echo "$key.$name: $val<br />\n";
}
}
?>
replacing
tests/test2.jpg
with
test/<?=$prod['image_url'] ?>
but the syntax is incorrect. Please suggest how it can be corrected.
modify
exif_read_data('test/<?=$prod['image_url'] ?>', 0, true);
to
exif_read_data('test/' . $prod['image_url'], 0, true);
Full code
$exif = exif_read_data('test/' . $prod['image_url'], 0, true);
echo "test2.jpg:<br />\n";
foreach ($exif as $key => $section) {
foreach ($section as $name => $val) {
echo "$key.$name: $val<br />\n";
}
}
?>
Error reason : You can't put php tag inside another php tag
ouch. ok, try this. It allows you to use the $prod['image_url'] in the string $filename and then pass $filename to the exif_read_data function.
<?php
$filename = sprintf("tests/%s",$prod['image_url']);
$exif = exif_read_data($filename, 0, true);
printf("%s<br/>",$filename);
foreach ($exif as $key => $section) {
foreach ($section as $name => $val) {
echo "$key.$name: $val<br />\n";
}
}
?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.