php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #23241 Perl's qq~~ and q~~ -> PHP?
Submitted: 2003-04-16 10:07 UTC Modified: 2003-04-17 18:47 UTC
From: kitdekat_yh at yahoo dot com Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 4.3.2RC1 OS: Win2K AdvSrv
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: kitdekat_yh at yahoo dot com
New email:
PHP Version: OS:

 

 [2003-04-16 10:07 UTC] kitdekat_yh at yahoo dot com
Perl has the ability to 'inline' HereDocs by using qq~~ (double quoting) and q~~ (single quoting) a portion of text exactly like a HereDoc does (parsing $vars while keeping nopn-escaped "s and 's as well) without taking up entire lines for start and end tags. Also the ~ symbol can be replaced by any character( q// and qq//, etc) that you wont be using within the string, and if you do, can be escaped to still print it out. It also allows for multiple HereDoc conversions on a single line, examples as follows: 

    echo <<< END_HERE1 
    remembers "quotes" and parses $vars 
    and 'remembers' new lines 
    END_HERE1;

    echo join("\n", $array_list); 

    echo <<< END_HERE2 
    and continues. 
    END_HERE2;

can be done as follows: 

    echo qq~... "quotes" and $vars\n~ . join("\n", $array_list) . qq~and ...\n~;

which allows more condensed code and, atleast i think, makes creating complex formatted HTML easier. This is not simply another alias btw (as mentioned in #12779) but a varying functionality that increases the power of PHP as seen in the examples. Since HereDocs do not do the q~~ (single quote version) at all nor do they function with multiples 'inline'd either.

I feel that this will alleviate many Perl convert's problems with formatting their pages a specific way and allow them to write however they need it written at the moment. 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-04-16 10:38 UTC] wez@php.net
PHP is not perl; we won't be implementing this syntax.
 [2003-04-17 18:47 UTC] kitdekat_yh at yahoo dot com
fine.. its open-source, i'll implement it myself.
make it into a patch for all future releases...

thanks for the support.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 22 20:00:03 2025 UTC