How to format within a language file

Discussion in 'PHP' started by sitefever, Jun 28, 2007.

Thread Status:
Not open for further replies.
  1. #1
    I have a language file in a script that's fully of a bunch of "define" veriables just like this:


    define('TITLE', 'Blah, blah blah');

    Then, on the page, it's called like this:

    <?php echo TITLE?>

    I was wondering how I can add just some basic formatting options to this, such as being able to display an apostrophe ' properly as well as being able to specify where a new line begins.

    There are a few variables in the language file that are quite lengthy and I don't like not being able to start a new line where I want and such.

    I was reading a little bit about htmlspecialchars... is this what I should use? And if so, how?

    Thanks!
     
    sitefever, Jun 28, 2007 IP
  2. xxKillswitch

    xxKillswitch Peon

    Messages:
    331
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can always include the ' inside your text when defining a constant, you just have to excape it with a \.

    Eg.
    <?php DEFINE'_TITLE','This wouldn\'t give off an error.'); ?>

    <?php echo _TITLE; ?>
    Would print This wouldn't give off an error. You can always use ' inside of tags that are enclosed with ' ' as long as you use the \ before.

    Hope that helps.
     
    xxKillswitch, Jun 28, 2007 IP
  3. sitefever

    sitefever Banned

    Messages:
    782
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yeah, I appreciate that information. How about for a line break, such as <br>?

    How do I insert line breaks within this type of file? Thanks a lot for your help.
     
    sitefever, Jun 28, 2007 IP
  4. xxKillswitch

    xxKillswitch Peon

    Messages:
    331
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You can enter the HTML inside of what you are defining regularly. In my language file, I have included <strong> and <a href tags and it hasn't given me any trouble. You should be able to just enter <br /> and be fine...

    <?php DEFINE('_TITLE','THis is a <br /> break.'); ?>
     
    xxKillswitch, Jun 28, 2007 IP
Thread Status:
Not open for further replies.