By Thomas Rutter

Multi-Line Strings and Text Editors

By Thomas Rutter

PHP conveniently allows two main methods of using multi-line strings, where a string constant is broken over many lines. However, it can be hard to find a syntax highlighting text editor that will correctly highlight multi-line strings in PHP.

When I was switched text editors recently, support for multi-line strings when syntax highlighting was high on my list of required features.

I find multi-line strings convenient for writing SQL, as writing a non-trivial SQL query on one line does not make for very readable code.

Here are two examples of multi-line strings in PHP. The first is simple a quoted string split over multiple lines.

$sql = "

This next example uses heredoc syntax, which allows you to specify a token to end the string with.

$sql =

The text editor I now use is Syn, which supports multi-line quoted strings but not heredoc syntax. Given the choice, I would rather use quoted strings than heredoc.

Here are all of the editors I evaluated.

Syn can highlight multi-line strings, but I found a couple of bugs in the latest version on their site, which is dated February 2004. Incidentally, if you email the developer, he'll be happy to give you a later build where the bugs are fixed. Alas, the fixes haven't made it into an official build.

I was very impressed with Notepad++ for its speed and responsiveness as well as for additional features such as code folding. Notepad++ does highlight multi-line strings correctly, but I couldn't find a way of showing a 'folder view' panel similar to that found in editors such as Syn, HTML-Kit, JEdit and Editplus. If anybody knows a way, please let me know.

TextPad does multi-line strings. What turned me off from this editor was that I couldn't find a folder view panel, and I couldn't specify bold or italic when setting up my syntax highlighting. The lack of bold and italic support is not as important to me.

JEdit does support multi-line strings in its syntax highlighting. It is a very impressive editor with a large range of plug-ins, but unfortunately I found it very slow to load. Responsiveness was one of my main criteria, and one of the reasons I chose the light-weight Syn for now.

UltraEdit looks great, but unfortunately does not have syntax highlighting for multi-line strings. According to their website, this will be supported in version 11.

Crimson editor is nice, but doesn't have support for multi-line strings. I don't know if this will be added in a future version.

HTML-Kit is a fantastic editor and used to be my editor of choice until relatively recently. While it supports heredoc syntax, it does not have support for regular multi-line strings in quotes. According to their FAQ, support will not be added and isn't available in a plugin due to architecture limitations. However, I'd definitely recommend this editor if you are not concerned with multi-line strings.

EditPlus has no support for multi-line strings, or for bold/italic when configuring syntax highlighting. Otherwise, it is very nice and has a folder view, and lots of nice extra features.

Why the need to support multi-line strings? It is just a personal preference of mine. There are alternative ways to achieve the same effect, however. For one, there is heredoc syntax, which is (to my surprise) supported by more editors that regular multi-line strings, though still not the majority. Other alternatives are workarounds such as the following:

$sql =
. " product.productid,"
. " product.title"
. "FROM"
. " product"
. " product.type='boardgame'";

I found adding those dots and quotes to be highly frustrating, however, even just now! It would make that SQL hard to maintain in future.

How do you deal with multi-line strings in your code? Do you write SQL on one line, break it into multiple strings, or use multi-line strings?

Note: Initially when I compiled this list, I wrote that JEdit does not support multi-line strings. Upon testing it today, I see that it does. I've corrected my mistake.

  • JEdit actually does support multiline strings. Its heredoc support is slightly flaky (it identifies the end delimiter of a heredoc even when it doesn’t occur after a line break), but it’s the best implementation I’ve found in a free editor.

  • I use SciTE, which is just a syntax highlighter for about 20 languages, but it does multiline strings fine in my experiences. It is free too :)

  • mmj

    Thanks for the link charmedlover. SciTE looks very nice – similar to Notepad++ in its features. Like Notepad++ however, I couldn’t find a file browser sidebar. Maybe I should adapt to not using one! Or am I missing something?

  • Ned Collyer

    UltraEdit does it.

    I’ve had 11.00a for around 1 month.

    I have yet to find a text/code editor better than ultraedit.

    InteliJ or Visual Studio for teh win :) if you are talking DEs

  • Matthew

    Vim ( handles both heredoc and multi-line strings without issue, and very responsively. It has both CLI and GUI versions available, and is available on just about any platform you could care to try (I’ve personally used it in Linux, Windows, Mac OS X, and some Unix terminals). It may take a while to accustom yourself to how it works, particularly if you normally use a mouse, but once you train yourself, it’s an incredibly responsive and flexible editor.

  • If anyone is looking for a direct link (I apologize for not posting it) you can find it here: It isn’t a large program, but it gets the job done for any project. Perfect for a small application that does one step up from NotePad.

  • Garret

    EmEditor ( is also a very nice editor that supports regex highlighting that you can set up. It could be made to work with heredoc syntax most likely.

  • Anonymous

    Ye Olde Emacs also supports the simple quoted multi-line string syntax. Theoretically, modes could support heredoc, but don’t. The built-in lexer has no concept of delimiters longer than three two characters.

  • Jimmy Cerra

    How long did it take for jEdit to load for you? I use it and there are various tricks you can do to get it loading much quicker, such as:

    * Delete unnecessary plugins, macros (even the built-in ones), and syntax formats.

    * Disable the splash screen and other unnecessary features.

    * Preload jEdit in the background via a command line switch and startup shortcut.

    Also load it once, and the next time it seems to load much quicker.

  • I’ve found Jedit to be pretty responsive and useful. The phpdebugger plugin will even highlight php errors, warnings as you edit.

  • Will Hardeman

    EditPlus does support multi-line strings, as long as you have your .stx file set up correctly. My understanding is that either the latest build or the next one will include support for heredoc format strings, as well. EditPlus has been my editor of choice for years. :-)

  • Joseph Scott

    As someone has already mentioned, Vim supports heredoc quite nicely. It will even correctly syntax highlight the content of the heredoc based on the text used to terminate the heredoc. So you can get SQL syntax highlighting in your heredoc content with:

    $sql =< < SELECT *
    FROM products
    WHERE product_id = 3

    And HTML syntax highlighting with:

    $html =< <


    Once I came across this feature I’ve used it for all my heredoc use ever since.

  • nik

    Notepad++ is based on SCite.
    On Scite website there’s link to Sidewinder – folder/files float addon to scite.

  • mhe

    i have discovered scite over 2 years ago. there is a complete php-ready out of the box package of scite which i make.

    included php4+php5, integrated php help file, special shortcuts, tidy and stuff ..

  • Berislav Lopac

    After searching for a while, I have found Komodo from ActiveState (, currently in version 3.1) to be the best editor for all my needs. It supports PHP, Python, TCL and Perl (as well as numerous other oft-encountered languages, such as Javascript, HTML, CSS, C/C++, XML), and while it’s not free it is a great investment if you program in any of these languages. If you use two or more of them regularly, it’s a must.

  • MiiJaySung

    I like jEdit very much. The loading time can be an issue, however I rarely switch the computer off (My windows box at home goes into hibernate, and the Mac at work sleeps).

    The big advantage for me in jEdit is that it works on Windows, Linux and Mac OS X, OS’s that I use on a daily basis.

    The big issue I have with many editors and using PHP is the lack of being able to integrate help. If anyone is looking for this on the Mac, you wanna look at TextMate (I dunno how it handles multiline heredoc strings though, however if you asked for it to be supported the author will do his best to implement it normally). The need for integrated help becomes a bigger issue for me if I use a machine that only has the one monitor as it means Apple/Alt Tabbing all of the time.

  • Biggus Dickus

    I’ve been using PHP Designer 2005 for a couple of months now and I think it’s pretty impressive. Support for PHP (and multi-line strings), HTML, CSS, XML, SQL and the combination of all. Only for Windows though…, but it’s free.

  • I noticed right away with UE11 that it supported multi-line strings, it’s great!

  • Sam

    Both BBEdit and TextMate support these types of strings in their syntax coloring

  • Dr Livingston

    i’ve tried ultraedit in the past and didn’t like it. can’t remember why :(

    i’m a recent convert to jedit though, and find it has a decent set of features. it is slow on start up i find, but so is a lot of other apps i use, such as firefox so it must be my pc.

    but what i do find about jedit is that it is fast, so if you find it unresponsive i don’t have this problem?

    i find that on windows with a java app, if you do a defrag this solves issues of sluggish useage for a while if it helps…

  • Sandy

    BBEdit 8.1 (possibly earlier) supports both.

  • Aake

    I have been using phpeclipse for about two months now, and although not perfect, it’s quite good. It highlights multi-line strings correctly, although “splitting” strings when you hit enter is turned on by default.

    I’d like to switch to jedit, but the ability in eclipse to visually compare files to their history prevents me from doing this.

  • Sam

    Wow, editor war flame bait? Reall?

    Ok. VIM is the answer, of course. Once you get good with a modal editor, you’ll never ever look back. All non-modal editors are just fancy HTML text boxes and we know how good those are for editing.

  • ermau

    There’s always Zend Studio, which has support for.. well.. just about everything you can think of when it comes to PHP.

  • Syn should support heredoc because it uses the SynEdit richtext editor control (also on sourceforge). I recently had this same issue with PHP Designer, and when I questioned the SynEdit guys about it, they said you have to compile it with heredoc enabled. So if Syn doesn’t support it, then I would guess that the Syn guys haven’t turned it on.

    I’m still a big fan of EditPlus. Just wish it had debugger intergration.

  • timnz

    Further to Will Hardeman’s comment, to enable multi-line strings in EditPlus your PHP.stx needs to have the following:

  • Dreamweaver doesn’t support heredoc :(

  • michin namja

    crimson editor does supports multi-line strings… you just have to add $MULTILINESTRINGCONSTANT=YES to the php.spc file located in the spec folder of the program directory.

  • I have recently started trying out Maguma Open Studio and have been pretty happy so far with the program. It seems to support both types of multi-line strings. It is also free, so very much worth checking out!

  • mmj

    [quote=michin namja]crimson editor does supports multi-line strings… you just have to add $MULTILINESTRINGCONSTANT=YES to the php.spc file located in the spec folder of the program directory.[/quote]

    Thanks for the tip Michin!

  • That’s probably my single complaint about EditPlus. The lack of heredoc. :(

  • Slightly OT, but I’m beginning to feel like I’m in a minority as a Linux user here! Does no-one else find it helpful to run and develop PHP code on linux???

    FWIW, I like using Kate (KDE only), Nedit (i think available for windows) and occasional stints on emacs.

    So there!

  • EditPlus now has syntax highlighting for heredoc. Download latest bugfix from

    Then simply add #HEREDOC=< << to your stx file (replace <<< with whatever suits the language you are using)

    To highlight multi-line quotes, use: #CONTINUE_QUOTE=y

Get the latest in Front-end, once a week, for free.