Use the -d option of php, like :

$ php -d memory_limit=1GB temp.php
string(3) "1GB"

If several values need to be defined, use another configuration file instead of the default. This is safer:
php -c /etc/phpcli.ini temp.php