Tech Tip: PHP Execute Results
PRODUCT: 4D | VERSION: 16 | PLATFORM: Mac & Win
Published On: December 8, 2017
When using PHP Execute, the output from a function or script executed can be returned to a 4D BLOB or a 4D TEXT. An issue can occur when a TEXT type is expected but a binary format is returned from the function. In these cases, it is often safer to send the results to a BLOB and then perform a conversion to a text.
For example, the following code will return a result if the execution returns a text format result but will be a null if the result is a binary format result.
C_TEXT($textResult) C_BOOLEAN($ok) $ok:=PHP Execute($scriptPath;"";$textResult) |
The following code will confirm that the text result is returned:
C_TEXT($textResult) C_BLOB($blobResult) C_BOOLEAN($ok) $ok:=PHP Execute($scriptPath;"";$blobResult) If (BLOB size($blobResult)>0) $textResult:=Convert to text($blobResult;"UTF-8") End if |
Related:
Tech Tip: Make sure to use the proper return value when using PHP EXECUTE