Home > Backend Development > PHP Tutorial > popen function calls local script and passes parameters

popen function calls local script and passes parameters

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-08-04 09:19:00
Original
1862 people have browsed it

The boss asked me to implement a function of sending emails asynchronously in PHP. I searched for information on the Internet and found that popen can be used, so I initially wrote it like this:

<code>pclose(popen("php -f mymail.php","r"));</code>
Copy after login
Copy after login

This script is an account that uses phpmailer to send an email to me.
Now I want to pass parameters to this function:
$to--recipient
$content--content
$subject--title.
These are essential for the function of sending emails,
but don’t know how to write them?
Are you adding parameters after this command? As follows, == Maybe this is more reliable

<code>php -f mymail.php -a $argv1 -b $argv2</code>
Copy after login
Copy after login

Is there still something that can pass parameters? (But the popen function has 4 parameters that are not the same)

<code>popen("balabala","r",$参数,$参数)</code>
Copy after login
Copy after login

Or should I force it to be written in and then use it directly? It means something like the following

<code>fopen("mymail.php","w");
fwrite $to balabala;
fwrite $subject balabala;
fclose(fopen(balabala));</code>
Copy after login
Copy after login

I am new to PHP, please forgive me if I have any mistakes, please give me your advice, ==

Reply content:

The boss asked me to implement a function of sending emails asynchronously in PHP. I searched for information on the Internet and found that popen can be used, so I initially wrote it like this:

<code>pclose(popen("php -f mymail.php","r"));</code>
Copy after login
Copy after login

This script is an account that uses phpmailer to send an email to me.
Now I want to pass parameters to this function:
$to--recipient
$content--content
$subject--title.
These are essential for the function of sending emails,
but don’t know how to write them?
Are you adding parameters after this command? As follows, == Maybe this is more reliable

<code>php -f mymail.php -a $argv1 -b $argv2</code>
Copy after login
Copy after login

Is there still something that can pass parameters? (But the popen function has 4 parameters that are not the same)

<code>popen("balabala","r",$参数,$参数)</code>
Copy after login
Copy after login

Or should I force it to be written in and then use it directly? It means something like the following

<code>fopen("mymail.php","w");
fwrite $to balabala;
fwrite $subject balabala;
fclose(fopen(balabala));</code>
Copy after login
Copy after login

I am new to PHP, please forgive me if I have any mistakes, please give me your advice, ==

Related labels:
php
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template