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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:53:07+00:00 2026-05-26T10:53:07+00:00

I am trying to run the following code: is_dir(‘~/tmp’); On a shared LAMP stack.

  • 0

I am trying to run the following code:

is_dir('~/tmp');

On a shared LAMP stack. It works fine, and returns TRUE. (That directory exists.) When I run the same code on my local box (Mac OSX 10.5, running Zend Server Community Ed) I get FALSE which is wrong because ~/tmp exists and has permissions set to 777.

I am missing a server directive somewhere, I think.

I have checked with phpInfo and I have (on both local and production):

safe_mode           Off         Off

safe_mode_exec_dir  no value    no value

safe_mode_gid           Off         Off

safe_mode_include_dir   no value    no value

open_basedir    no value    no value

So I think that I am missing something, but what?

[edit…] Some more information…

running the following on my local

get_current_user()

gives me ‘username’, which is the correct user whose ~/tmp directory I want to verify, BUT

shell_exec('whoami')

gives me ‘daemon’. So I think I know where my problem is coming from. Now I just need to figure out if/how I can change the user that is running the web server on my local.

  • 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-26T10:53:08+00:00Added an answer on May 26, 2026 at 10:53 am

    Are you expecting ~ to be expanded to your home directory? I would be reluctant to rely on that inside of PHP. (Just tested it on my Mac, and it did not expand.)

    If possible, try changing ~/tmp to whatever the full path name is (e.g., something like /Users/meriial/tmp).

    UPDATE: Alternatively, you could replace ~ with $_ENV['HOME'] as follows:

    is_dir($_ENV['HOME'] . '/tmp');
    

    Ideally, you’d check that array_key_exists('HOME',$_ENV) returns TRUE first and take some appropriate action (like use the system temp dir) if it doesn’t.

    For that matter, as @xmarcos points out, you could just use the system temp dir regardless using sys_get_temp_dir() and tempnam(). That may be the most portable and therefore your best choice. I think you can also do atomic temp file creation that way, so it may be more secure and less prone to race conditions.

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

Sidebar

Related Questions

I am trying to run the following code from within Eclipse: Process process =
I'm trying to run the following code with Ninject.Moq: [TestMethod] public void TestMethod1() {
I am trying to run the following ruby code from IRB but am unable
I am trying to run the following code to loop around a recordset and
I am trying to run following code: $a = array('aa'); function my_func (& $m)
I'm trying to run the following code in eclipse but the console remains blank
I am trying to run the following code with MonoTouch: this.TouchesBegan += delegate {
I am trying to run the following code: 1. NSURL *checkLicenseURL = [NSURL URLWithString:@check_license.php?accesskey=&license_key=];
I am trying to run the following code within SQLPlus: exec lbacsys.sa_sysdba.create_policy(policy_name => 'ACCESS_LOCATIONS',
I'm trying to run the following code, written on my local machine: http://www.jsfiddle.net/WShdx/3/ Functionality-wise

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.