Jump to content

Recommended Posts

I'm not sure what you mean.  

 

In a web context (php being used with a web server) any output that is returned via echo or printf will be sent to the client as html by default.  print_r, var_dump and var_export are special helper functions that will give you some sort of output even when you pass them an object or array.  They are for quick and dirty debugging.  echo is your standard way of returning data to the browser as html.

Link to comment
https://forums.phpfreaks.com/topic/295365-scandir/#findComment-1508545
Share on other sites

Great.  Also just a tip, Print and echo are the same function.  Most people use echo, because it's shorter.  

 

Printf came over from the 'C' language  and uses formatting placeholders and parameters.  There are some cases when you want to control things like the exact format of a number where printf can be attractive, although there are often a number of different ways to accomplish the same thing in php, and for the most part it's personal preference.

  • Like 1
Link to comment
https://forums.phpfreaks.com/topic/295365-scandir/#findComment-1508581
Share on other sites

Great.  Also just a tip, Print and echo are the same function.  Most people use echo, because it's shorter.  

 

 

Sorry, Gizmola, but going to have to argue with you over that one.

 

1. print returns a value (always 1), echo does not (void function)

 

2. echo will accept multiple arguments whereas with print you have to use concatenation eg

echo 'Today is ', date('Y-m-d');           // multi args works
print 'Today is ', date('Y-m-d');           // multi args  - error
print 'Today is '. date('Y-m-d');           // concatenation works
  • Like 2
Link to comment
https://forums.phpfreaks.com/topic/295365-scandir/#findComment-1508585
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.