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

  • Home
  • SEARCH
  • 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 1065147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T19:45:53+00:00 2026-05-16T19:45:53+00:00

How can defined global variable ($begin) that will be recognized in all php file?

  • 0

How can defined global variable ($begin) that will be recognized in all php file?
(please dont change the case code only add, because I working on big project that i can only add code)

Case:(problem $begin not recognized in the end of the file)

<?php $begin=time()?>
  <div>new name</div>
<?php   echo time()-$begin; ?>

Edit:
I have stupid mistake in file, now the code works, thanks

Thanks

  • 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-16T19:45:54+00:00Added an answer on May 16, 2026 at 7:45 pm

    You use, constants as they have global scope.

    <?php define('TS_START',time())?>
      <div>new name</div>
    <?php   echo time()-TS_START; ?>
    

    or if you cant do that because of your “large” project. maybe you want to double var it.

    <?php $begin = $_begin = $__begin = time()?>
      <div>new name</div>
    <?php   echo time()- ($begin ? $begin : ($_begin ? $_begin : $__begin)); ?>
    

    poor programming though, there’s no need for that many vars for one small entity, I would rewrite with define and overwrite all instances of $begin with TS_START

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

Sidebar

Related Questions

I originally had an array[1..1000] that was defined as a global variable. But now
(Follow-up to my earlier question, Ruby: how can I copy a variable without pointing
I am creating a multipage form in PHP, using a session. The $stage variable
I'm new to python, so please excuse what is probably a pretty dumb question.
I have a set of jQuery plugins I'm creating for a website. All of
UPD. 0xC0000005 is STATUS_ACCESS_VIOLATION , defined in winnt.h. Meaning the app has tried to
In a .NET project I need to verify if a string is a valid
I`m writing a chat using WinSock2 and WinAPI functions. And I have a little
We have a very large JavaScript application, where after many months of coding there
I'd like to make program-wide data in a C++ program, without running into pesky

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.