By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,949 Members | 1,869 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,949 IT Pros & Developers. It's quick & easy.

php printing problem

P: n/a
I am having the problem with php printing

print true; // prints 1
print false // dosent print anything

Thanks!!!
Aug 13 '08 #1
Share this Question
Share on Google+
7 Replies


P: n/a
*** raashid bhatt escribió/wrote (Wed, 13 Aug 2008 10:06:34 -0700 (PDT)):
I am having the problem with php printing

print true; // prints 1
print false // dosent print anything
print needs strings so this is a conversion from boolean into string. These
are the rules:

http://es2.php.net/manual/en/languag...string.casting

"A boolean TRUE value is converted to the string "1". Boolean FALSE is
converted to "" (the empty string). This allows conversion back and forth
between boolean and string values."

You may find var_dump() useful.

--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor en cubitos: http://www.demogracia.com
--
Aug 13 '08 #2

P: n/a
print's overrated, good ol echo, tried and true and also fast than
print (if ever speed did count)
Aug 13 '08 #3

P: n/a
..oO(The Hajj)
>print's overrated, good ol echo, tried and true and also fast than
print (if ever speed did count)
The only little difference is in semantics, not in speed. In practice it
won't matter anyway.

Micha
Aug 13 '08 #4

P: n/a
..oO(raashid bhatt)
>I am having the problem with php printing

print true; // prints 1
print false // dosent print anything
If casted to a string, a FALSE will become the empty string, which makes
perfect sense and is described in the manual.

Micha
Aug 13 '08 #5

P: n/a
On Aug 13, 3:10 pm, Michael Fesser <neti...@gmx.dewrote:
.oO(The Hajj)
print's overrated, good ol echo, tried and true and also fast than
print (if ever speed did count)

The only little difference is in semantics, not in speed. In practice it
won't matter anyway.

Micha
I'm going off language construct versus function but yeah, I've never
ran into where I've noticed a difference.
Aug 13 '08 #6

P: n/a
..oO(The Hajj)
>On Aug 13, 3:10 pm, Michael Fesser <neti...@gmx.dewrote:
>.oO(The Hajj)
>print's overrated, good ol echo, tried and true and also fast than
print (if ever speed did count)

The only little difference is in semantics, not in speed. In practice it
won't matter anyway.

Micha

I'm going off language construct versus function but yeah, I've never
ran into where I've noticed a difference.
JFTR: Both are language constructs. Indeed 'print' behaves more like a
function, though (it sets a return value), but still doesn't require
parentheses.

Micha
Aug 13 '08 #7

P: n/a
On Aug 13, 3:19 pm, Michael Fesser <neti...@gmx.dewrote:
.oO(The Hajj)
On Aug 13, 3:10 pm, Michael Fesser <neti...@gmx.dewrote:
.oO(The Hajj)
print's overrated, good ol echo, tried and true and also fast than
print (if ever speed did count)
The only little difference is in semantics, not in speed. In practice it
won't matter anyway.
Micha
I'm going off language construct versus function but yeah, I've never
ran into where I've noticed a difference.

JFTR: Both are language constructs. Indeed 'print' behaves more like a
function, though (it sets a return value), but still doesn't require
parentheses.

Micha
hmm, I'll have to go inform someone of this, was told print = function
Aug 13 '08 #8

This discussion thread is closed

Replies have been disabled for this discussion.