I assume it's not possible, but you never know until you're sure...
Would come handy sometimes....
Adding comments to a multiline echo.
Moderator: General Moderators
-
Shendemiar
- Forum Contributor
- Posts: 404
- Joined: Thu Jan 08, 2004 8:28 am
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
all really depends how you are setting it up..
for example
look into [php_man]hightlight_string[/php_man].
It would be a lot more helpful if you described what you are really looking on doing.
for example
Code: Select all
<?php
//it is possible... notice how this is doing it
?>It would be a lot more helpful if you described what you are really looking on doing.
I assume you mean something like....
In which case, yes it is possible.
Code: Select all
<?php
echo "Hello " . // Hello
"World"; // World
?>-
Shendemiar
- Forum Contributor
- Posts: 404
- Joined: Thu Jan 08, 2004 8:28 am
This'll do great, thanks once again matesredmonkey wrote:I assume you mean something like....In which case, yes it is possible.Code: Select all
<?php echo "Hello " . // Hello "World"; // World ?>
-
Hi,
the way suggested is possible, but not very handy I guess.
I prefer this instead: (Has also the advantage, that the comment starts in column 3 and not in 80 or more and is readable/accessable very easy.)
djot
-
Hi,
the way suggested is possible, but not very handy I guess.
I prefer this instead: (Has also the advantage, that the comment starts in column 3 and not in 80 or more and is readable/accessable very easy.)
Code: Select all
// comments for foo1
$text .= "foo1"
// comments for foo2
$text .= "foo2"
...
echo $text;-
I think it is all down to personal preference and which ever you find easier to work with. I had to put together a long string today which I wanted to comment and chose to do it like this.....
Had I choosen your preference it would have been...
For me personally I find it can be quite difficult to pick out the code bits from in between all those comments in the second example.
But, with the first example (for me anyway) the comments are out of the way and don't distract me from the code flow but not to far away that I can't get to them should I need to refer to them.
Code: Select all
<?php
$unpack = 'vversion/' // version made by (2 bytes)
. 'vextract_version/' // version needed to extract (2 bytes)
. 'vgp_bit/' // general purpose bit (2 bytes)
. 'vmethod/' // compression method (2 bytes)
. 'Vmod_time/' // last modified time and date (4 bytes)
. 'Vcrc32/' // crc32 (4 bytes)
. 'Vc_len/' // compressed length (4 bytes)
. 'Vuc_len/' // uncompressed length (4 bytes)
. 'vfn_len/' // length of filename (2 bytes)
. 'vef_len/' // extra field length (2 bytes)
. 'vfcom_len/' // file comment length (2 bytes)
. 'vdisk_start/' // disk number start (2 bytes)
. 'vin_fa/' // internal file attributes (2 bytes)
. 'Vex_fa/' // external file sttributes (4 bytes)
. 'Voffset'; // relative offset of local header (4 bytes)
?>Code: Select all
<?php
// version made by (2 bytes)
$unpack = 'vversion/';
// version needed to extract (2 bytes)
$unpack .= 'vextract_version/';
// general purpose bit (2 bytes)
$unpack .= 'vgp_bit/';
// compression method (2 bytes)
$unpack .= 'vmethod/';
// last modified time and date (4 bytes)
$unpack .= 'Vmod_time/';
// crc32 (4 bytes)
$unpack .= 'Vcrc32/';
// compressed length (4 bytes)
$unpack .= 'Vc_len/';
// uncompressed length (4 bytes)
$unpack .= 'Vuc_len/';
// length of filename (2 bytes)
$unpack .= 'vfn_len/';
// extra field length (2 bytes)
$unpack .= 'vef_len/';
// file comment length (2 bytes)
$unpack .= 'vfcom_len/';
// disk number start (2 bytes)
$unpack .= 'vdisk_start/';
// internal file attributes (2 bytes)
$unpack .= 'vin_fa/';
// external file sttributes (4 bytes)
$unpack .= 'Vex_fa/';
// relative offset of local header (4 bytes)
$unpack .= 'Voffset';
?>But, with the first example (for me anyway) the comments are out of the way and don't distract me from the code flow but not to far away that I can't get to them should I need to refer to them.