474,044 Members | 3,039 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Pass octal value to function

Does anyone know how to pass an octal value to a function
successfully?
I am trying to create a class to handle directory permissions but
passing the permission settings is going nowhere.

Octals seem to automatically get converted to decimal when sent and
when trying to convert back using decoct the 0 is dropped.
I have also tried sending as a string but chmod() does not accept
string input and I haven't been able to convert back to a number &
retain the leading 0.

Thanks

sample.

test(0777);

function test($myvar){
echo "PASSED VAL:".$myvar;
// PASSED VAL:511
echo "DECOCT:".decoc t($myvar);
// DECOCT:777
echo "STRING:".(('0' .decoct($myvar) )*1);
// STRING:777
Jul 17 '05 #1
2 4301
"Brad-H" <br*******@gmai l.com> wrote in message
news:63******** *************** ***@posting.goo gle.com...
Does anyone know how to pass an octal value to a function
successfully?
I am trying to create a class to handle directory permissions but
passing the permission settings is going nowhere.

Octals seem to automatically get converted to decimal when sent and
when trying to convert back using decoct the 0 is dropped.
I have also tried sending as a string but chmod() does not accept
string input and I haven't been able to convert back to a number &
retain the leading 0.

Thanks

sample.

test(0777);

function test($myvar){
echo "PASSED VAL:".$myvar;
// PASSED VAL:511
ok so what's wrong there? i guess if you'd pass the (decimal) 511 to chmod,
it'll interpret it just like it'd interpret a literal 0777.
echo "DECOCT:".decoc t($myvar);
// DECOCT:777
echo "STRING:".(('0' .decoct($myvar) )*1);
// STRING:777


try
echo "STRING:". '0'.(decoct($my var)*1);

you first prepended the '0', making it a string, and then multiplied by 1,
turning it into an integer again.
Jul 17 '05 #2
You could just send the octal as a string -> "0777" instead of just
0777. PHP is pretty loose, strings and integers can be interchanged.

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
2232
by: Sean McIlroy | last post by:
I recently found out that unicode("\347", "iso-8859-1") is the lowercase c-with-cedilla, so I set out to round up the unicode numbers of the extra characters you need for French, and I found them all just fine EXCEPT for the o-e ligature (oeuvre, etc). I examined the unicode characters from 0 to 900 without finding it; then I looked at www.unicode.org but the numbers I got there (0152 and 0153) didn't work. Can anybody put a help on me wrt...
1
3318
by: Stan | last post by:
The convert method allows us to change any base number (bin, octal, hex ) to decimal, but how can I change a decimal value back to an octal number??? Thanks in advance Stan
27
7916
by: fuch6921 | last post by:
I want to read in an Octal number argument and have it stored as an octal number. For instance the user will type: ./a.out 777 and it will store the octal number 777. But it atoi does this as an interger, and sscanf gives me 0.
15
35578
by: jaks.maths | last post by:
How to convert negative integer to hexadecimal or octal number? Ex: -568 What is the equivalent hexadecimal and octal number??
14
20467
by: Abhi | last post by:
I wrote a function foo(int arr) and its prototype is declared as foo(int arr); I modify the values of the array in the function and the values are getting modified in the main array which is passed also. I understand that this way of passing the array is by value and if the prototype is declared as foo(int *), it is by reference in which case the value if modified in the function will get reflected in the main function as well. I dont...
7
11396
by: Gary Brown | last post by:
Hi, I have a whole bunch of integer constants that are best given in octal (PDP-1 opcodes). It makes a huge difference in readability and authenticity if these can be entered in octal. I haven't found a way to do this. Is there one? Thanks, Gary
10
13710
by: Robert Dailey | last post by:
Hi, I noticed in Python all function parameters seem to be passed by reference. This means that when I modify the value of a variable of a function, the value of the variable externally from the function is also modified. Sometimes I wish to work with "copies", in that when I pass in an integer variable into a function, I want the function to be modifying a COPY, not the reference. Is this possible?
6
2736
by: lisp9000 | last post by:
I've read that C allows two ways to pass information between functions: o Pass by Value o Pass by Reference I was talking to some C programmers and they told me there is no such thing as pass by reference in C since you are just passing an address (or a pointer value address I guess?). So I was wondering is this correct?
10
3619
by: laurent.pauloin | last post by:
Hello, I would like to print a signed octal. With a signed short it's printf %hi but what about an octal ? Tk !
0
10337
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
12140
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11602
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
12022
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
11141
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
10309
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8698
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7868
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
3
3971
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.