Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6170455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:02:20+00:00 2026-05-23T23:02:20+00:00

in php i wrote my own debug function which have two arguments: text and

  • 0

in php i wrote my own debug function which have two arguments: text and a level of message. However i could be also you the php functions for triggering errors. But to debug in development i use sometimes like this:

debug($xmlobject->asXML(),MY_CONSTANT);

now i want to know whether it is a lack of performance in non debug executing because the arguments are calculated indepent whether they will be used inside function? and how to do that right that is only calculated if i need?

Thanks for your help,
Robert

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T23:02:21+00:00Added an answer on May 23, 2026 at 11:02 pm

    If you write the following portion of code :

    debug($xmlobject->asXML(),MY_CONSTANT);
    

    Then, no matter what the debug() function does, $xmlobject->asXML() will be called and executed.

    If you do not want that expression to be evaluated, you must not call it; I see two possible solutions :

    • Remove the useless-in-production calls to the debug() function, not leaving any debugging code in your source files,
    • Or make sure they are only executed when needed.

    In the second case, a possibility would be to define a constant to configure whether or not you are in debug-mode, and, then, only call debug() when needed :

    if (DEBUG) {
        debug($xmlobject->asXML(),MY_CONSTANT);
    }
    

    Of course, the makes writting debbuging-code a bit harder… and there is a bit of performance-impact (but far smaller than executing the actual code for nothing).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote my own mvc for php, and it seems to be working fine
I have a PHP script that uses cURL to access a file also located
I'd like to write my own GUI text edit for HTML, CSS and PHP.
I have a two dimensional array in php and I want to get the
I'm searching for a way to use named arguments for sprintf or printf .
I have a bunch of ErrorDocument directives in my .htaccess file in order to
I finally wrote a script to get Google Analytics data then insert it into
I developed a web platform in PHP a year ago, and I was kinda
I was following this tutorial of Sencha Touch: http://www.vimeo.com/15672696 Perfect tutorial, worked flawless. But
From this code. <form method=get> <div align=center><textarea name=post ></textarea></div> <div align=center><input type=submit value=Submit></div> </form>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.