having a semi collin in a variable?
- blah569
-
blah569
- Member since: Jan. 18, 2005
- Offline.
-
- Forum Stats
- Member
- Level 25
- Programmer
How can I do that? Example:
$variable =
"
some code goes here...;
some more here;
";
I hope you understand. Please help. Thanks.
- Gutya
-
Gutya
- Member since: Nov. 27, 2006
- Offline.
-
- Forum Stats
- Member
- Level 07
- Blank Slate
In PHP?
You can have a semi-colon in strings.
- blah569
-
blah569
- Member since: Jan. 18, 2005
- Offline.
-
- Forum Stats
- Member
- Level 25
- Programmer
No... you will get a error. It will day like "unexpected T_END" if you have it in a string.
- Jessii
-
Jessii
- Member since: Feb. 10, 2005
- Offline.
-
- Forum Stats
- Member
- Level 36
- Movie Buff
Can't you put it in quotes so that it comes up as text?
- blah569
-
blah569
- Member since: Jan. 18, 2005
- Offline.
-
- Forum Stats
- Member
- Level 25
- Programmer
this is what I am trying to do:
$code =
"
$sql_un = '$un';
$sql_pw = '$pw';
$sql_host = '$host';
$sql_db = '$db';
mysql_connect('$sql_host','$sql_pw','$sql_pw' )or die('ZarginBB Error #1<br><br>Can't connect to the database. Ask one of the admins for help.');
mysql_select_db('$sql_db')or die('ZarginBB Error #2<br><br>Can't select the database. Contact the admin.");
";
- Gutya
-
Gutya
- Member since: Nov. 27, 2006
- Offline.
-
- Forum Stats
- Member
- Level 07
- Blank Slate
Why does all that need to go into a string?
And it's better to do multi-line strings with heredoc.
Example:
$string = <<<IDENTIFIER
String
contents
here
you can even ouput $variables without escaping the string.
INDENTIFIER;
echo $string;
Where IDENTIFIER tells PHP where to start and end the string, it can be anything you want, but I usually make it upper-case to avoid confusion.
- blah569
-
blah569
- Member since: Jan. 18, 2005
- Offline.
-
- Forum Stats
- Member
- Level 25
- Programmer
At 12/3/06 06:39 PM, Gutya wrote: Why does all that need to go into a string?
And it's better to do multi-line strings with heredoc.
Thanks. I will try that =).
- DFox
-
DFox
- Member since: Aug. 9, 2003
- Offline.
-
- Forum Stats
- Member
- Level 30
- Blank Slate
$code =
'
$sql_un = \'$un\';
$sql_pw = \'$pw\';
$sql_host = \'$host\';
$sql_db = \'$db\';
mysql_connect(\'$sql_host\',\'$sql_pw\',\'$sq l_pw\' )or die(\'ZarginBB Error #1<br><br>Can\'t connect to the database. Ask one of the admins for help.\');
mysql_select_db(\'$sql_db\')or die(\'ZarginBB Error #2<br><br>Can\'t select the database. Contact the admin.");
';
?
- henke37
-
henke37
- Member since: Sep. 10, 2004
- Offline.
-
- Forum Stats
- Member
- Level 30
- Blank Slate
Have you heard of functions? You sure does not act like you have.
Each time someone abuses hittest, God kills a kitten. Please, learn real collision testing.
- authorblues
-
authorblues
- Member since: Jun. 21, 2005
- Offline.
-
- Forum Stats
- Member
- Level 12
- Blank Slate
At 12/4/06 02:59 AM, henke37 wrote: Have you heard of functions? You sure does not act like you have.
how is that relevant? i just guess i missed the point...



