|
| 1 | +<?xml version="1.0" encoding="utf-8"?> |
| 2 | +<!-- $Revision$ --> |
| 3 | +<refentry xml:id="function.ini-parse-quantity" xmlns="http://docbook.org/ns/docbook"> |
| 4 | + <refnamediv> |
| 5 | + <refname>ini_parse_quantity</refname> |
| 6 | + <refpurpose>Get interpreted size from ini shorthand syntax</refpurpose> |
| 7 | + </refnamediv> |
| 8 | + |
| 9 | + <refsect1 role="description"> |
| 10 | + &reftitle.description; |
| 11 | + <methodsynopsis> |
| 12 | + <type>int</type><methodname>ini_parse_quantity</methodname> |
| 13 | + <methodparam><type>string</type><parameter>shorthand</parameter></methodparam> |
| 14 | + </methodsynopsis> |
| 15 | + <para> |
| 16 | + Returns the interpreted size in bytes on success from an <link linkend="faq.using.shorthandbytes">ini shorthand</link>. |
| 17 | + </para> |
| 18 | + </refsect1> |
| 19 | + |
| 20 | + <refsect1 role="parameters"> |
| 21 | + &reftitle.parameters; |
| 22 | + <para> |
| 23 | + <variablelist> |
| 24 | + <varlistentry> |
| 25 | + <term><parameter>shorthand</parameter></term> |
| 26 | + <listitem> |
| 27 | + <para> |
| 28 | + Ini shorthand to parse, must be a number followed by an optional multiplier. |
| 29 | + |
| 30 | + The followig multipliers are supported: <literal>k</literal>/<literal>K</literal> (<literal>1024</literal>), |
| 31 | + <literal>m</literal>/<literal>M</literal> (<literal>1048576</literal>), |
| 32 | + <literal>g</literal>/<literal>G</literal> (<literal>1073741824</literal>). |
| 33 | + |
| 34 | + The number can be a decimal, hex (prefixed with <literal>0x</literal> or <literal>0X</literal>), |
| 35 | + octal (prefixed with <literal>0o</literal>, <literal>0O</literal> or <literal>0</literal>) or binary (prefixed with |
| 36 | + <literal>0b</literal> or <literal>0B</literal>) |
| 37 | + </para> |
| 38 | + </listitem> |
| 39 | + </varlistentry> |
| 40 | + </variablelist> |
| 41 | + </para> |
| 42 | + </refsect1> |
| 43 | + |
| 44 | + <refsect1 role="returnvalues"> |
| 45 | + &reftitle.returnvalues; |
| 46 | + <para> |
| 47 | + Returns the interpreted size in bytes as an &integer;. |
| 48 | + </para> |
| 49 | + </refsect1> |
| 50 | + |
| 51 | + <refsect1 role="errors"> |
| 52 | + &reftitle.errors; |
| 53 | + <para> |
| 54 | + If the value cannot be parsed, or an invalid multiplier is used, an <constant>E_WARNING</constant> is raised. |
| 55 | + </para> |
| 56 | + </refsect1> |
| 57 | + |
| 58 | + <refsect1 role="examples"> |
| 59 | + &reftitle.examples; |
| 60 | + <para> |
| 61 | + <example> |
| 62 | + <title>A few <function>ini_parse_quantity</function> examples</title> |
| 63 | + <programlisting role="php"> |
| 64 | +<![CDATA[ |
| 65 | +<?php |
| 66 | +
|
| 67 | +var_dump(ini_parse_quantity('1024')); |
| 68 | +var_dump(ini_parse_quantity('1024M')); |
| 69 | +var_dump(ini_parse_quantity('512K')); |
| 70 | +var_dump(ini_parse_quantity('0xFFk')); |
| 71 | +var_dump(ini_parse_quantity('0b1010k')); |
| 72 | +var_dump(ini_parse_quantity('0o1024')); |
| 73 | +var_dump(ini_parse_quantity('01024')); |
| 74 | +var_dump(ini_parse_quantity('Foobar')); |
| 75 | +var_dump(ini_parse_quantity('10F')); |
| 76 | +
|
| 77 | +?> |
| 78 | +]]> |
| 79 | + </programlisting> |
| 80 | + &example.outputs.similar; |
| 81 | + <screen> |
| 82 | +<![CDATA[ |
| 83 | +
|
| 84 | +int(1024) |
| 85 | +int(1073741824) |
| 86 | +int(524288) |
| 87 | +int(261120) |
| 88 | +int(10240) |
| 89 | +int(532) |
| 90 | +int(532) |
| 91 | +
|
| 92 | +Warning: Invalid quantity "Foobar": no valid leading digits, interpreting as "0" for backwards compatibility |
| 93 | +int(0) |
| 94 | +
|
| 95 | +Warning: Invalid quantity "10F": unknown multiplier "F", interpreting as "10" for backwards compatibility |
| 96 | +int(10) |
| 97 | +
|
| 98 | +]]> |
| 99 | + </screen> |
| 100 | + </example> |
| 101 | + </para> |
| 102 | + </refsect1> |
| 103 | + <refsect1 role="seealso"> |
| 104 | + &reftitle.seealso; |
| 105 | + <simplelist> |
| 106 | + <member><function>ini_get</function></member> |
| 107 | + </simplelist> |
| 108 | + </refsect1> |
| 109 | +</refentry> |
| 110 | +<!-- Keep this comment at the end of the file |
| 111 | +Local variables: |
| 112 | +mode: sgml |
| 113 | +sgml-omittag:t |
| 114 | +sgml-shorttag:t |
| 115 | +sgml-minimize-attributes:nil |
| 116 | +sgml-always-quote-attributes:t |
| 117 | +sgml-indent-step:1 |
| 118 | +sgml-indent-data:t |
| 119 | +indent-tabs-mode:nil |
| 120 | +sgml-parent-document:nil |
| 121 | +sgml-default-dtd-file:"~/.phpdoc/manual.ced" |
| 122 | +sgml-exposed-tags:nil |
| 123 | +sgml-local-catalogs:nil |
| 124 | +sgml-local-ecat-files:nil |
| 125 | +End: |
| 126 | +vim600: syn=xml fen fdm=syntax fdl=2 si |
| 127 | +vim: et tw=78 syn=sgml |
| 128 | +vi: ts=1 sw=1 |
| 129 | +--> |
0 commit comments