2013-02-19 81 views
0

我正在將一些Coldfusion代碼翻譯成PHP,並試圖弄清楚如何執行「二進制編碼」功能。這是我的代碼 - 它需要一長串十六進制字符並將它們輸出爲GIF圖像。翻譯CF的二進制編碼爲PHP

<cfset GIF = "CCFFCC....."> 
<cfset output = binarydecode(GIF,'Hex')> 
<cfcontent type="image/gif" reset="yes" variable="#output#"> 

我已經看過binarydecode的原始輸出(),並在所有的二進制,十六進制,並在PHP圖像功能,但無法找到合適的組合,以獲得相同的輸出。

對此提出建議?

+0

可能的重複 - http://stackoverflow.com/questions/6382738/convert-string-to-binary-then-back-again-using-php?如果不是那麼那麼 - http://www.hotscripts.com/forums/php/47235-solved-how-transfer-string-binary.html? – 2013-02-19 04:43:02

回答

0

找到了答案。對於發生的事情並不是一個真正的解釋,但至少可以完成這項工作。本頁內容:http://www.drupaluser.org/php_manual/function.pack.html

我發現了這個,它將可比較的結果返回給binarydecode()。

$output = pack("H".strlen($GIF),$GIF);