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 7637243
In Process

The Archive Base Latest Questions

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

If I have the following file: <?php namespace SampleProject; hello_world(); and this in a

  • 0

If I have the following file:

<?php
namespace SampleProject;

hello_world();

and this in a separate file:

<?php
function hello_world() {

}

Is there anyway for the hello_world() function to get the namespace of the file that called it (So SampleProject)

  • 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-31T07:53:19+00:00Added an answer on May 31, 2026 at 7:53 am

    Depends on what you want to do with that namespace information, but you could add a parameter to the function and then call it like this:

    hello_world(__NAMESPACE__);
    

    read more about the __NAMESPACE__ constant in the php documentation.

    Adding __NAMESPACE__ inside your function will simply give an empty string since your function is not inside of a namespace.

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

Sidebar

Related Questions

I have the following code: if (include_once(dirname(__FILE__).'/file.php') || include_once(dirname(__FILE__).'/local/file.php') ) { This causes an
I have a PHP script that does the following: Uses file_get_contents() to get content
In PHP I have the following code that gets a file submitted through CGI:
I have the following javascript into a index.php file: <script type=text/javascript> $('.showpics, .showpics2').live('click', function()
I have the following PHP script being called by AJAX: <?php // file /ajax/loopback.php
I have a section of code like the following: ---- file.php ---- require_once(mylib.php); function($a,$b)
I have the following: window.setTimeout(function() { window.location.href = 'file.php'; }, 115000); How can I,
I have the following function. This function is called with a setTimeout upon a
Really stumped on this one. I have the following PHP file with a variable
I have the following in my config/routes.php file: $route['(:any)'] = dashboard/index/$1; This works as

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.