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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:47:00+00:00 2026-05-17T23:47:00+00:00

Ok test 1 and 2 work fine, but If I cast the value from

  • 0

Ok test 1 and 2 work fine, but If I cast the value from an array it doesn’t work.

$file = '/test/file.xlsx';
echo "Original Permissions: ".substr(decoct(fileperms($file)),2)."<br />\n\r";

// test 1
$permission = 0775;
chmod($file,$permission);
clearstatcache();
echo "Test 1 Permissions: ".substr(decoct(fileperms($file)),2)."<br />\n\r";

// test 2
define("PERMISSION", 0775);
chmod($file,PERMISSION);
clearstatcache();
echo "Test 2 Permissions: ".substr(decoct(fileperms($file)),2)."<br />\n\r";

Output:

Original Permissions: 1407<br />
Test 1 Permissions: 0775<br />
Test 2 Permissions: 0775<br />

Why doesn’t this work?

// $ini_array['excel_file_info']['excel_file_permission'] 
// is in a ini file with the value set to 0775
if(isset($ini_array['excel_file_info']['excel_file_permission'])) {
    $excel_file_permission  = $ini_array['excel_file_info']['excel_file_permission'];  
    define("EXCEL_FILE_PERMISSION", $excel_file_permission);
} else {
    $excel_file_permission  = 0777; 
    define("EXCEL_FILE_PERMISSION", $excel_file_permission);
}

echo "Permissions Before chmod: ".substr(decoct(fileperms($file)),2)."<br />\n\r";
chmod($file,EXCEL_FILE_PERMISSION);
clearstatcache();
echo "Permissions After chmod: ".substr(decoct(fileperms($file)),2)."<br />\n\r";;
chmod($file,0755);
clearstatcache();
echo "Permissions Hard Coded chmod: ".substr(decoct(fileperms($file)),2)."<br />\n\r";;

I get this for file permissions:

// Before I chmod
Permissions Before chmod: 0644<br />

// Using the DEFINED CONSTANT w/ set value to 0775
Permissions After chmod: 1363<br />

// Hard Coded 0755
Permissions Hard Coded chmod: 0755<br />

EDIT:

// test 3
$permission = array('perm' => 0775);
chmod($file,$permission['perm']);
clearstatcache();
echo "Test 3 Permissions: ".substr(decoct(fileperms($file)),2)."<br />\n\r";

Test 3 works, but still not the main example. UGH!!!

EDIT #2:

I think I found the problem, when I echo the type of the variable it’s a string.

echo "Defined Excel File Permission: ".EXCEL_FILE_PERMISSION."\n\r";
echo "Defined Type: ".gettype(EXCEL_FILE_PERMISSION)."\n\r";

Defined Excel File Permission: 0775
Defined Type: string

Why is this?

  • 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-17T23:47:01+00:00Added an answer on May 17, 2026 at 11:47 pm

    I think typecasting cause the problem. Try to change:

    $excel_file_permission  = (int)$ini_array['excel_file_info']['excel_file_permission'];
    

    to

    $excel_file_permission  = intval($ini_array['excel_file_info']['excel_file_permission'], 8);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to test this out on my site but it doesn't quite work
How come the following doesn't work? CREATE FUNCTION Test (@top integer) RETURNS TABLE AS
As title. ruby test/functionals/whatevertest.rb doesn't work, that requires me to replace all require 'test_helper'
I have this and all seems to work fine but not sure why and
I've created a website that used to work fine. But now Firebug throws me
Hi I'm trying to fix a bit of test html to work with opera/chrome.
I work for a medical transcription company and our medical transcription test we administer
I have (after quite a bit of work) a web test that will upload
I have test database and a production database. When developing I of course work
Is there such a thing as unit test generation? If so... ...does it work

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.