Forum Moderators: coopster

Message Too Old, No Replies

print function won't print?

         

aceskull

7:08 am on Apr 7, 2004 (gmt 0)

10+ Year Member



I have been using echo in PHP but I saw most examples use the print function so I tried it, but It wouldn't display anything on the page, I am trying this on a localhost. I used echo instead and it works...so I was just wondering what is it that I haven't setup that the print function isn't working.

this was the code i used

session_start();
print($counter);
$counter++;
session_register("counter");

coopster

4:19 pm on Apr 7, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



echo [php.net] and print [php.net] are very similar except that
print
always returns
1
, which means that
print
can be used as part of a more complex expression where
echo
cannot.

Also, neither is actually a real function (it is a language construct) so you are not required to use parentheses with the argument list. In fact, if you want to pass more than one parameter to

echo
, you must not enclose the parameters within parentheses.

If you turn on error_reporting [php.net], you will start getting a lot more information to help you get through your coding issues. There are some good Troubleshooting [webmasterworld.com] techniques in the WebmasterWorld PHP Library [webmasterworld.com].

I would guess that nothing is showing up here because you haven't established any value in the

$counter
variable. You are printing it before you are setting it.

aceskull

3:28 pm on Apr 8, 2004 (gmt 0)

10+ Year Member



thank you so much coopster for your help. The library, error_reporting and troubleshootinig are great! Seems like thats all I need it to make things work. Ans yes you were correct, I was trying a tutorial off of an website and I forgot to register the counter var. but for that stupid mistake you gave me so much more....... thanks again