in reply to Re^3: Calling a PHP function from within Perl
in thread Calling a PHP function from within Perl

Thanks friend. I'm not quite there yet.
PHP Notice: Undefined variable: fromName in /etc/my/lib/sendMail-cli. +php on line 4 PHP Notice: Undefined variable: fromEmail in /etc/my/lib/sendMail-cli +.php on line 4 PHP Notice: Undefined variable: to in /etc/my/lib/sendMail-cli.php on + line 4 PHP Notice: Undefined variable: cc in /etc/my/lib/sendMail-cli.php on + line 4 PHP Notice: Undefined variable: bcc in /etc/my/lib/sendMail-cli.php o +n line 4 PHP Notice: Undefined variable: subject in /etc/my/lib/sendMail-cli.p +hp on line 4 PHP Notice: Undefined variable: messageHtml in /etc/my/lib/sendMail-c +li.php on line 4 PHP Notice: Undefined variable: messageText in /etc/my/lib/sendMail-c +li.php on line 4 Invalid address: Invalid address:
Any ideas?

Replies are listed 'Best First'.
Re^5: Calling a PHP function from within Perl
by tobyink (Canon) on Aug 02, 2019 at 10:56 UTC

    Did you use extract() right? This is a PHP function that loops through an associative array (think "hash" in Perl), and creates a local variable for each top-level key.

    So instead of doing:

    <?php $myarray = array( "foo" => 1, "bar" => 2, "baz" => 3, ); $foo = $myarray["foo"]; $bar = $myarray["bar"]; $baz = $myarray["baz"];

    You can just do:

    <?php $myarray = array( "foo" => 1, "bar" => 2, "baz" => 3, ); extract($myarray);

    The keys will be case-sensitive, so make sure you're capitalizing them the same in the PHP and the Perl script that feeds it.

    Alternatively, abandon using extract() and just access stuff in the array normally. I mostly only used extract() to keep the example PHP file I wrote very small and simple.