SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot cholmon's Avatar
    Join Date
    Mar 2004
    Location
    SC
    Posts
    197
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy [php] tag doesn't like back slashes?

    Check out this snippet, using the "code" tag:
    Code:
    /**
     * use some\long\name\space as mylib;
     */
    
    use some\long\name\space as mylib;
    ...compared to the exact same snippet in a "php" code block:
    PHP Code:
    /**
     * use some\long\name\space as mylib;
     */

    use some\long\name\space as mylib
    SP's syntax highlighter seems to strip backslashes from PHP code, though it leaves them in the comments.
    Drew C King: PHP Developer
    <?= $short_tags++ ?>

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,789
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    \ escapes the character following eg. \n = new line, \t = tab, \\ = backslash
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    SitePoint Zealot cholmon's Avatar
    Join Date
    Mar 2004
    Location
    SC
    Posts
    197
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by felgall View Post
    \ escapes the character following eg. \n = new line, \t = tab, \\ = backslash
    Nope, already tried that:
    Code:
    /**
     * use some\\long\\name\\space as mylib;
     */
    
    use some\\long\\name\\space as mylib;
    PHP Code:
    /**
     * use some\\long\\name\\space as mylib;
     */

    use some\\long\\name\\space as mylib
    ...any other ideas?
    Drew C King: PHP Developer
    <?= $short_tags++ ?>

  4. #4
    SitePoint Enthusiast dyer85's Avatar
    Join Date
    Nov 2004
    Location
    L2 cache.
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, the native PHP highlight_string(), for example, works as expected. vBulletin, however, seems to replace one or more backslashes with none.

    However, you can use the other syntax highlighter (which I presume is GeSHi)

    Code php:
    <?php
     
    use Foo\Bar\Baz as Quux;
     
    echo Quux\somefunc();

    Actual BBCode:
    Code:
    [highlight=php]
    <?php
    
    use Foo\Bar\Baz as Quux;
    
    echo Quux\somefunc();
    [/highlight]
    "Structure padding is the use of extraneous materials to
    enhance the shape of a struct and make it more attractive
    to members of the opposite struct. (see also 'struct
    silicone.')" -- Eric Sosman

  5. #5
    SitePoint Zealot cholmon's Avatar
    Join Date
    Mar 2004
    Location
    SC
    Posts
    197
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Very cool...I didn't know there was an alternative way to highlight syntax. Thanks!
    Drew C King: PHP Developer
    <?= $short_tags++ ?>


Bookmarks

Posting Permissions

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