Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
PHP: octdec - Manual
[go: Go Back, main page]

PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

pi" width="11" height="7"/> <mt_srand
Last updated: Sun, 25 Nov 2007

view this page in

octdec

(PHP 4, PHP 5)

octdec — 8 進数を 10 進数に変換する

説明

number octdec ( string $octal_string )

octal_string により指定された 8 進数を 10 進数表現した数値を返します。

パラメータ

octal_string

変換したい 8 進文字列。

返り値

octal_string を 8 進で表した値を返します。

変更履歴

バージョン 説明
4.1.0 以降 この関数は、integer 型の範囲をこえる大きな数値も変換できるようになりました。 そのような値は、float で返します。

Example#1 octdec() の例

<?php
echo octdec('77') . "\n";
echo 
octdec(decoct(45));
?>

上の例の出力は以下となります。

63
45



pi" width="11" height="7"/> <mt_srand
Last updated: Sun, 25 Nov 2007
 
add a note add a note User Contributed Notes
octdec
harry at disgruntledgoat dot com
27-Mar-2007 08:03
Calling the sticky bit "text" is not erroneous: On UNIX back in 1974, it instructed the operating system to retain the text segment of the program in swap space after the process exited. This speeded subsequent executions by allowing the kernel to make a single operation of moving the program from swap to real memory.
11-Sep-2002 05:51
The 'S' flag for Unix file access rights is badly computed in the above sample.
If the corresponding 'x' bit (exec) is not set, and the 's' bit (setgid/setuid/sticky) is set, then the flag should not be displayed as and uppercase 'S', but as a lower case 's'. Also the sticky bit (mainly used for folders with public right access rights such as /tmp to protect against deletion by non owner) is badly named ("text"?).
meheler at searchbc dot com
26-Oct-2001 12:03
This function and decoct work great when working with file permissions. For example:

<?php
    $mode
= octdec('4750');
   
   
$user['suid']     = ($mode & 04000);
   
$user['read']     = ($mode & 00400);
   
$user['write']    = ($mode & 00200);
   
$user['execute']  = ($mode & 00100);
   
   
$group['sgid']    = ($mode & 02000);
   
$group['read']    = ($mode & 00040);
   
$group['write']   = ($mode & 00020);
   
$group['execute'] = ($mode & 00010);
   
   
$other['text']    = ($mode & 01000);
   
$other['read']    = ($mode & 00004);
   
$other['write']   = ($mode & 00002);
   
$other['execute'] = ($mode & 00001);
   
   
$attrs = array('-','-','-','-','-','-','-','-','-','-');
   
    if (
$system['dir']) $attrs[0] = 'd';
   
    if (
$user['read']) $attrs[1] = 'r';
    if (
$user['write']) $attrs[2] = 'w';
    if (
$user['execute']) $attrs[3] = 'x';
    if (
$user['suid']) $attrs[3] = 'S';
   
    if (
$group['read']) $attrs[4] = 'r';
    if (
$group['write']) $attrs[5] = 'w';
    if (
$group['execute']) $attrs[6] = 'x';
    if (
$group['sgid']) $attrs[6] = 'S';

    if (
$other['read']) $attrs[7] = 'r';
    if (
$other['write']) $attrs[8] = 'w';
    if (
$other['execute']) $attrs[9] = 'x';
    if (
$other['text']) $attrs[9] = 'T';
   
    echo
'<pre>';
    echo
'Mode Decimal: ' . $mode . "\n";
    echo
'Mode Octal: ' . decoct($mode) . "\n";
    echo
'Mode String: ' . implode('',$attrs)."\n";
    echo
'</pre>';
?>

Outputs:

Mode Decimal: 2536
Mode Octal: 4750
Mode String: -rwSr-x---

-Mike

pi" width="11" height="7"/> <mt_srand
Last updated: Sun, 25 Nov 2007
 
 
show source | credits | sitemap | contact | advertising | mirror sites