如何将查询发送到PHP页面并获取PHP中的HTML数据?

I am trying to send a html email from a php class in which the data is determined by the data sent to the class's method.

for example.

public function send_warning_email($user_id, $email){
   global $mail;
   $body = file_get_contents('email_processor.php');
   /// ohter codes  
}

In above example. I want to send query to the email_processor.php page and get the return plain text and assign it to the $body variable.

Is there another function I can use instead of file_get_contents() that will allow me to send query to the php page and get return text or another approach to performing this task?.

Use CURL

$ch = curl_init();  
curl_setopt($ch, CURLOPT_URL,'email_processor.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$data);     
// receive server response ...
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);

some OS will only read it when you pass it like this:

$body = file_get_contents('./email_processor.php');

You can require your email_processor.php:

$body = require 'email_processor.php';

In this case you must return some body in your email_processor.php

Another case: you can use output buffer:

ob_start();
require 'email_processor.php';
$body = ob_get_clean();

In this case you must echo some body in your email_processor.php