php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #68249 Implement another string delimiter as alternative to double quotes
Submitted: 2014-10-17 07:48 UTC Modified: 2017-08-05 04:55 UTC
Votes:2
Avg. Score:3.0 ± 2.0
Reproduced:1 of 2 (50.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: work at web-sav dot de Assigned:
Status: Suspended Package: Scripting Engine problem
PHP Version: Irrelevant OS: Irrelevant
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
22 - 12 = ?
Subscribe to this entry?

 
 [2014-10-17 07:48 UTC] work at web-sav dot de
Description:
------------
How to merge together HTML/JS/SQL and PHP inside non-view scripts:

// looks messy
$htmlSingle = '<a href="' . {$url} . '">' . {$label} . '</a>';

// good, but needs to be escaped
$htmlDouble = "<a href=\"{$url}\">{$label}</a>;

// breaks code clearity (especially inside classes)
$htmlHeredoc = <<<HTML
<a href="{$url}">{$label}</a>
HTML;

None of the above solutions are really perfect for solving one of the most common task in PHP. So a mixture of the heredoc syntax (code injection for phpstorm) and the double quotes (one liners) would be perfect imo. Maybe something like this:

// without code injection feature
$html = :|<a href="{url}">{$label}</a>|;

// with code injection
$html = :HTML|<a href="{url}">{$label}</a>|;



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-06-28 21:00 UTC] stas@php.net
-Package: PHP Language Specification +Package: Scripting Engine problem
 [2015-08-08 14:14 UTC] cmb@php.net
FWIW, you can also do

  $html = sprintf('<a href="%s">%s</a>', $url, $label);
 [2017-08-05 04:55 UTC] stas@php.net
-Status: Open +Status: Suspended
 [2017-08-05 04:55 UTC] stas@php.net
Thank you for your interest in PHP and for submitting a feature request. Please be aware that due to the magnitude of change this request requires, it would be necessary to discuss it on PHP Internals list (internals@lists.php.net) as an RFC. Please read the guide about creating RFCs here:
https://wiki.php.net/rfc/howto
If you haven't had experience with writing RFCs before, it is advised to seek guidance on the Internals list (http://php.net/mailing-lists.php) and/or solicit help from one of the experienced developers. 

Please to not consider this comment as a negative view on the merits of your proposal - every proposal which requires changes of certain magnitude, even the very successful and widely supported ones, must be done through the RFC process. This helps make the process predictable, transparent and accessible to all developers.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 07:01:29 2024 UTC