在变量中包含文件

Thank you all for your help ; I found many responses to my questions on this forum but still stuck on this one . Let me explain: I have files called “participant_pledge.php” , “parents_pledge.php” …. That contain text only. The reason for it is that this text is needed in many files within my website; so I simply use “include” wherever I need it. My problem is that I also need to include those file in the content of some “email function.” That’s where I can’t find solution to include those file since it isn’t possible to use a function within a variable. The idea would be to be able to do the following:

function update ($user_id, $update_camper_data) {
...
$message='
 ...
<tr>
<td>
Participant\'s Name*:
</td>
<td>
'.$update_camper_data['participant_first_name'].'  '.$update_camper_data['participant_middle_initial'].'  '.$update_camper_data['participant_last_name'].'
</td>

include ‘participant_pledge.php;  //which does not work inside a variable

...';
mail($to, $subject, $message, $headers);
}

I have considered constant variables but could not make it work (but maybe I used it the wrong way)… Anyways, thank you in advance for your time and help on this question.

Mike.

It is in fact possible in a way to use a 'function within a variable'. See: http://www.php.net/manual/en/functions.anonymous.php. The pattern you are describing is basically that ofa 'View Helper'. Maybe look at some frameworks and how they implement this. For example: http://framework.zend.com/manual/1.12/en/zend.view.helpers.html

Perhaps you should look into storing the text in a database. That way, all you'll need to do is query the database, instead of including the "text only" PHP files.