Results 1 to 20 of 20
  1. #1
    ABW Ambassador Snib's Avatar
    Join Date
    January 18th, 2005
    Location
    Virginia
    Posts
    5,303
    Do you "echo" or "print" in your PHP?
    I don't know about you guys but I was never an "echo" person, I've always been a "print" kinda guy. Maybe it comes from my background in BASIC and C++, I dunno. Seeing as PHP supports both which do you use?

    As a rule I never print in my production code though. I use it for debugging mostly.

    - Scott
    Hatred stirs up strife, But love covers all transgressions.

  2. #2
    ABW Ambassador isellstuff's Avatar
    Join Date
    November 9th, 2005
    Location
    Virginia
    Posts
    1,659
    var_dump love it.
    Merchants, any data you provide to Google Shopping should also be in your affiliate network datafeed. More data means more sales!

  3. #3
    ABW Ambassador Snib's Avatar
    Join Date
    January 18th, 2005
    Location
    Virginia
    Posts
    5,303
    Quote Originally Posted by isellstuff
    var_dump love it.
    Now if you want to get into that, I prefer print_r over var_dump

    - Scott
    Hatred stirs up strife, But love covers all transgressions.

  4. #4
    ABW Ambassador
    Join Date
    January 18th, 2005
    Posts
    551
    When I first started with PHP I had a real dilemma about this and I decided to use echo. I sometimes use print to comment my development scripts.

    Doing it that way means that I can easily search for “print” and delete my development comments when the script is finished.

    I don’t think it matters though.

  5. #5
    ABW Veteran Mr. Sal's Avatar
    Join Date
    January 18th, 2005
    Posts
    6,795
    Quote Originally Posted by Snib
    I don't know about you guys but I was never an "echo" person, I've always been a "print" kinda guy. Maybe it comes from my background in BASIC and C++, I dunno. Seeing as PHP supports both which do you use?

    As a rule I never print in my production code though. I use it for debugging mostly.

    - Scott
    Way back when I was into BASIC, I was used to the "print" command a lot, specially after getting use to type a lot of long BASIC code lines for games to use on my Tandy.

    But after I started learning and playing around with PHP for the last couple of years, I only use "echo" now, I guess I am hook on "echo", because if I am working on any PHP script and I see any "print", I would change it to "echo", just for the habit of it.

    (Btw, I like to do the same thing with the <strong> and <b> tags on html)

  6. #6
    ABW Ambassador Daniel M. Clark's Avatar
    Join Date
    January 7th, 2006
    Location
    Houston, TX
    Posts
    2,082
    echo and var_dump for me I don't think I've ever used print, although I must say, I'm still very young as far as PHP experience.
    Daniel M. Clark
    Tech Manager
    Greg Hoffman Consulting

  7. #7
    Grandma broke her coccyx! Uncle Rico's Avatar
    Join Date
    May 8th, 2007
    Location
    North Carolina
    Posts
    2,238
    I use echo.

    Technically speaking, echo is faster, but not that you would notice. Why? Php print has a return call and php echo does not.

  8. #8
    Lite On The Do, Heavy On The Nuts Donuts's Avatar
    Join Date
    January 18th, 2005
    Location
    Winter Park, FL
    Posts
    6,930
    I just echo, never print.

    My preference is... my ode to the Bunnymen.

  9. #9
    Beachy Bill's Avatar
    Join Date
    November 20th, 2005
    Posts
    8,266
    When I first started exploring with PHP, the first example told me to "echo" HELLO WORLD. I still consider myself a rank amateur compared to you guys, but I've been sticking with "echo" ever since that first lesson.
    Bill / Marketing Blog @ 12PM - Current project: Resurrecting my "baby" at South Baltimore..
    Cute Personal Checks and Business Checks
    If you are too busy to laugh you are too busy.

  10. #10
    Not that fat. ReallyBigGuy's Avatar
    Join Date
    July 20th, 2005
    Location
    U wish U knew
    Posts
    745
    print

  11. #11
    Comfortably Numb John Powell's Avatar
    Join Date
    October 17th, 2005
    Location
    Bayou Country, LA
    Posts
    3,432
    I use print right before a loop and after finishing a loop with echo inside. Now don't ask me why. I settle on something like that and can never remember why.


  12. #12
    Affiliate Manager buyjewelry's Avatar
    Join Date
    January 18th, 2005
    Posts
    400
    I use echo - don't know why. But thanks seymour for the technical reason why it's better.

  13. #13
    Yup, Sure ... now let me check ... Cagles Mill's Avatar
    Join Date
    January 18th, 2005
    Location
    The Midwest
    Posts
    646
    I've written a lot of programs over the years in a lot of programming languages and when I think of "print", I think of a command that is designed to send something to the printer. When I want PHP to generate some results I want the results "echoed" to the monitor so those results can be viewed. So... I use echo.
    Rick M.
    I would rather have a bottle in front of me, than have a frontal lobotomy!
    Does your bubblegum lose its flavor on the bedpost overnight?

  14. #14
    ABW Ambassador PatrickAllmond's Avatar
    Join Date
    September 20th, 2005
    Location
    OKC
    Posts
    1,219
    I am not sure how many people got Donuts! joke!

    I use echo.

    And to the person who adds print in as development comments then removes them ; add a testing/debug variable at the top of your script:

    $testing = true;

    Then for your echos/prints only do them if you are testing:

    if ($testing)
    echo "<br>Admin Password = $adminpass ";

    You can then set $testing = false when you don't want to debug. It keeps your debugging information in there for when you might want it for the future.
    ---
    This response was masterly crafted via the fingers of Patrick Allmond who believe you should StopDoingNothing starting today.
    ---
    Focus Consulting is where I roll | Follow @patrickallmond on Twitter
    Search Engine Marketing | Search Engine Optimization | Social Media | Online Video

  15. #15
    Affiliate Manager buyjewelry's Avatar
    Join Date
    January 18th, 2005
    Posts
    400
    Patrick - I didn't get it, but google helped

  16. #16
    Full Member
    Join Date
    March 10th, 2006
    Posts
    466
    Haven't settled on either one yet so still use both.

    Nice tip there Patrick.

  17. #17
    ABW Ambassador Daniel M. Clark's Avatar
    Join Date
    January 7th, 2006
    Location
    Houston, TX
    Posts
    2,082
    Quote Originally Posted by patrick24601
    I am not sure how many people got Donuts! joke!
    I did
    Daniel M. Clark
    Tech Manager
    Greg Hoffman Consulting

  18. #18
    Fear and Arrogance jrrl's Avatar
    Join Date
    January 18th, 2005
    Location
    Pittsburgh
    Posts
    485
    echo.

    Not because of the bunnymen, although that by itself would be an excellent reason.

    -John.
    There's a reason army's wear uniforms even though it makes them easier to spot. Sometimes that's what you want. Uniforms suggest organization, power, and numbers. These, in turn, inspire fear. And, as any good operative knows, there is no more effective weapon than fear.

    Hosting Comparison - HostScope - jrrl.com

  19. #19
    Full Member
    Join Date
    January 18th, 2005
    Posts
    396
    echo - it's shorter and I'm lazy

  20. #20
    Affiliate Manager cbsturg's Avatar
    Join Date
    January 24th, 2007
    Location
    Lima OH
    Posts
    753
    echo and print_r.

    The first tutorials I used had me use print, but every other example I saw on the net used echo and I slowly moved over.
    Chris Sturgill
    "All my life I've had one dream, to achieve my many goals." - H. Simpson

  21. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. What is time frame from "Low Funds" to "Temporarily Offline"
    By purplebear in forum ShareASale - SAS
    Replies: 5
    Last Post: January 16th, 2009, 05:24 PM
  2. Replies: 2
    Last Post: July 29th, 2005, 01:51 PM
  3. Datafeeds & Google: bad "news" - Are you a "thin affiliate" ?
    By heisje in forum Programming / Datafeeds / Tools
    Replies: 4
    Last Post: June 29th, 2005, 08:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •