Best Practices: working with long, multiline strings in PHP?

前端 未结 10 2102
感情败类
感情败类 2020-11-27 09:59

Note: I\'m sorry if this is an extremely simple question but I\'m somewhat obsessive compulsive over the formatting of my code.

I have a class that has a function th

10条回答
  •  野性不改
    2020-11-27 10:49

    I use templates for long text:

    email-template.txt contains

    hello {name}!
    how are you? 
    

    In PHP I do this:

    $email = file_get_contents('email-template.txt');
    $email = str_replace('{name},', 'Simon', $email);
    

提交回复
热议问题