www.webdeveloper.com
Results 1 to 2 of 2

Thread: [RESOLVED] Inserting PHP variables into imported HTML template

  1. #1
    Join Date
    Dec 2013
    Location
    Melbourne, Australia
    Posts
    25

    resolved [RESOLVED] Inserting PHP variables into imported HTML template

    Not sure if this is possible but I will give an overview of what I'm trying to achieve.

    I am building a notification email - basically it is just going to send a notification email to the administrator indicating whether the process was successful or unsuccessful.

    The email is the same every time except I will change the following values:
    - Customer Name
    - File Name
    - File Details
    - Time of Day

    What I was hoping to do was build the HTML template and simply include it in the PHP class, replacing the place holder with the actual variable information I generate when processing a file.

    Is this possible or will it require a custom built script to do a find and replace?

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    18,924
    I would just make the template PHP code itself.
    PHP Code:
    function getEmailText($custName$fileName$fileDetails$time)
    {
        
    $text = <<<EOD
    Blah blah blah $custName.

    Yadda yadda 
    $fileName yadda $fileDetails yadda yadda.

    Et cetera, et cetera, and so forth at 
    $time.

    The end.
    EOD;
        return 
    $text;

    Then just call that function in your email script wherever you need that text, supplying the 4 parameters that change for each message.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles