October 23, 2024
Chicago 12, Melborne City, USA
PHP

php – Escape php variables in exec()


I wish I could use rename() function in php; but I get "ERROR: Cross-device link" when trying to move a file/directory across mounted file systems.

So I rewrote code using system( "mv -i '$from' '$to'", $res);

This works fine when $from contains spaces; but when $from contains single quote; I get sh: no closing quote.

How best to resolve this issue? I reviewed the "similar questions" but they all relate to SQL.



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video