可以动态地将PDF转换为SWF吗?我一直在努力,但事实证明这很困难。
这是我的代码:
<?php
include('include\settings.php');
$title = "k";
$makeswf= mysql_query("SELECT * FROM books WHERE title = '$title'");
$rows = mysql_num_rows($makeswf);
if ($rows !=0)
{
while($rows = mysql_fetch_assoc($makeswf))
{
//where blocation is the pdf file need to be converted.
$file = $rows['blocation'];
echo exec('D:\wamp\www\dspzlibrary\converter\pdf2swf.exe books\$file.pdf -o books\$file.swf -f -T 9 -t -s storeallcharacters');
}
}
else
echo"empty";
?>
这是我收到的错误:
错误无法打开books \ $ file.pdf
任何帮助将不胜感激。
答案 0 :(得分:1)
错误消息告诉您发生了什么。可执行文件pdf2swf.exe
正在尝试打开$file.pdf
,而不是实际的文件名。
在PHP中,您需要双引号“”表示内联变量替换。
echo exec("D:\wamp\www\dspzlibrary\converter\pdf2swf.exe books\$file.pdf -o books\$file.swf -f -T 9 -t -s storeallcharacters");
请参阅:http://php.net/manual/en/language.types.string.php
双引号字符串最重要的特性是变量名称将被扩展。