Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-11-2002, 12:48 PM   PM User | #1
chrisvmarle
Regular Coder

 
Join Date: Jun 2002
Location: the Netherlands
Posts: 215
Thanks: 0
Thanked 0 Times in 0 Posts
chrisvmarle is an unknown quantity at this point
Question Something like qq~Text~; (from Perl) in PHP?

In Perl I use qq~Some text~; a lot and I'm looking for something like this in PHP.

For those who don't know perl, let me explain what it does:
It enables you to write on multiple lines without extra functions (is possible in PHP with just the "Text [new line] more text")
But it also makes it possible to write text whitout have to escape all characters; like ", <, $, etc.

Anyone?

Thanks in advance,
Mzzl, Chris
chrisvmarle is offline   Reply With Quote
Old 07-11-2002, 02:16 PM   PM User | #2
Flamerule
New Coder

 
Join Date: Jun 2002
Location: Paris, France
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Flamerule is an unknown quantity at this point
In php to write on a new line just do
PHP Code:
echo "some text \n more text on another line" 
Note : This will make a new line in the source code. If you want a new line on the screen you need to replace the \n by <br>
You don't need to escape $ and < in php. Just " or ' and \ I think
__________________
I don't suffer from insanity, I enjoy every single minute of it!
Flamerule is offline   Reply With Quote
Old 07-11-2002, 02:48 PM   PM User | #3
bcarl314
Mega-ultimate member


 
Join Date: Jun 2002
Location: Winona, MN - The land of 10,000 lakes
Posts: 1,855
Thanks: 1
Thanked 45 Times in 42 Posts
bcarl314 will become famous soon enough
Also,

If your in a conditional loop I think this works (although I haven't tried it)

<?php
if(some_condition) {//write if condition is true
?>

<table border="5" cellpadding="1">
<tr><td>This is the life, I'm going to write a backslash \.</td></tr>
</table>

<?php
}// end writing
else {// begin writing for false condition
?>

Nope ain't gonna do it! OK?

<?php
}// end false condition writing
?>
bcarl314 is offline   Reply With Quote
Old 07-11-2002, 03:40 PM   PM User | #4
Flamerule
New Coder

 
Join Date: Jun 2002
Location: Paris, France
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Flamerule is an unknown quantity at this point
Cool

It does work

And not only in conditions, just anywhere
__________________
I don't suffer from insanity, I enjoy every single minute of it!
Flamerule is offline   Reply With Quote
Old 07-11-2002, 03:44 PM   PM User | #5
mordred
Senior Coder


 
Join Date: Jun 2002
Location: frankfurt, german banana republic
Posts: 1,848
Thanks: 0
Thanked 0 Times in 0 Posts
mordred is an unknown quantity at this point
Additionally, perhaps the heredoc syntax is suited to your needs. Although it parses variables still... have a look at

http://www.php.net/manual/en/language.types.string.php
mordred is offline   Reply With Quote
Old 07-11-2002, 05:41 PM   PM User | #6
Feyd
Regular Coder


 
Feyd's Avatar
 
Join Date: May 2002
Location: Los Angeles, CA Maxim: Subvert Society
Posts: 404
Thanks: 0
Thanked 0 Times in 0 Posts
Feyd is an unknown quantity at this point
You an also just exit out of the PHP block and print HTML directly (which is, technically, faster than doing ECHO, from a machine speed/time point of view). Of course, then you are going to have to enclose any of your variables with <?= and ?>.

PHP Code:
<?
    
//preceding code, if any
    
if ($c['noticestat']) {
    
//html block
?>
    <html lang="en_US">
        <head>
            <title><?=$title['curvar'];?></title>
        </head>
        <body bgcolor="#000000" marginheight="0" marginwidth="0" topmargin="0" leftmargin="0">
            <table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%">
                <tr>
                    <td width="100%" height="100%" align="center" valign="middle" class="noticeTxt"><?=$c['noticemess'];?><br/>
                    <br/>.( <?=$c['sitename'];?> ).</td>
                </tr>
            </table>
        </body>
    </html>
<?
    
}
    
//back to PHP
    //additional code, if any
?>
Edit : evil missing bracket!
__________________
Moderator, Perl/CGI Forum
shadowstorm.net - subvert society

Last edited by Feyd; 07-11-2002 at 06:01 PM..
Feyd is offline   Reply With Quote
Old 07-11-2002, 08:35 PM   PM User | #7
chrisvmarle
Regular Coder

 
Join Date: Jun 2002
Location: the Netherlands
Posts: 215
Thanks: 0
Thanked 0 Times in 0 Posts
chrisvmarle is an unknown quantity at this point
That "exiting" PHP is a good idea and solves my problem, for a part, but I'd also like to know if there's a way in wich I don't have to escape "...

Thanks to all of you for your help.
chrisvmarle is offline   Reply With Quote
Old 07-11-2002, 09:23 PM   PM User | #8
Jeewhizz
Regular Coder


 
Join Date: May 2002
Location: London, England
Posts: 369
Thanks: 0
Thanked 0 Times in 0 Posts
Jeewhizz is an unknown quantity at this point
Yup, this can be done... like so

PHP Code:
echo<<<code
<form name="edit=web"  method="post" action="edit_Prem_table.php?edit=1&id=<?=row[id];?>">                        
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr> 
      <td valign="middle" width="20%"> 
        <div align="center">
code;
print $row["team"];
echo<<<code
</div>
      </td>
      <td width="20%" valign="middle"> 
        <div align="center"> 
          <input type="text" class="formfield" name="newplayed" size="2" value="
code;
Hope that is clear... the code thingcan be anyhting!

Jee
__________________
Jeewhizz - MySQL Moderator
http://www.sitehq.co.uk
PHP and MySQL Hosting
Jeewhizz is offline   Reply With Quote
Old 07-11-2002, 09:59 PM   PM User | #9
chrisvmarle
Regular Coder

 
Join Date: Jun 2002
Location: the Netherlands
Posts: 215
Thanks: 0
Thanked 0 Times in 0 Posts
chrisvmarle is an unknown quantity at this point
Thanks, that's it
chrisvmarle is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:01 PM.


Advertisement
Log in to turn off these ads.