| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 
 | <?xml version="1.0" encoding="utf-8"?>
 <reference id="ref.misc">
  <title>Miscellaneous functions</title>
  <titleabbrev>Misc.</titleabbrev>
  <partintro>
   <para>
    These functions were placed here because none of the other
    categories seemed to fit.
   </para>
  </partintro>
  <refentry id="function.connection-aborted">
   <refnamediv>
    <refname>connection_aborted</refname>
    <refpurpose>Returns &true; if client disconnected</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>int</type><methodname>connection_aborted</methodname>
      <methodparam><type>void</type><parameter/></methodparam>
     </methodsynopsis>
    <simpara>
     Returns &true; if client disconnected.  See the <link
     linkend="features.connection-handling">Connection Handling</link>
     description in the <link linkend="features">Features</link>
     chapter for a complete explanation.
    </simpara>
   </refsect1>
  </refentry>
  <refentry id="function.connection-status">
   <refnamediv>
    <refname>connection_status</refname>
    <refpurpose>Returns connection status bitfield</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>int</type><methodname>connection_status</methodname>
      <methodparam><type>void</type><parameter/></methodparam>
     </methodsynopsis>
    <simpara>
     Returns the connection status bitfield.  See the <link
     linkend="features.connection-handling">Connection Handling</link>
     description in the <link linkend="features">Features</link>
     chapter for a complete explanation.
    </simpara>
   </refsect1>
  </refentry>
  <refentry id="function.connection-timeout">
   <refnamediv>
    <refname>connection_timeout</refname>
    <refpurpose>Return &true; if script timed out</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>int</type><methodname>connection_timeout</methodname>
      <methodparam><type>void</type><parameter/></methodparam>
     </methodsynopsis>
    <simpara>
     Returns &true; if script timed out.    See the <link
     linkend="features.connection-handling">Connection Handling</link>
     description in the <link linkend="features">Features</link>
     chapter for a complete explanation.
    </simpara>
   </refsect1>
  </refentry>
  <refentry id="function.define">
   <refnamediv>
    <refname>define</refname>
    <refpurpose>Defines a named constant.</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>int</type><methodname>define</methodname>
      <methodparam><type>string</type><parameter>name</parameter></methodparam>
      <methodparam><type>mixed</type><parameter>value</parameter></methodparam>
      <methodparam choice="opt"><type>int</type><parameter>case_insensitive</parameter></methodparam>
     </methodsynopsis>
    <para>
     Defines a named constant, which is similar to a variable except:
     <itemizedlist>
      <listitem>
       <simpara>
    Constants do not have a dollar sign '$' before them;
       </simpara>
      </listitem>
      <listitem>
       <simpara>
    Constants may be accessed anywhere without regard to variable
    scoping rules;
       </simpara>
      </listitem>
      <listitem>
       <simpara>
    Constants may not be redefined or undefined once they have
    been set; and
       </simpara>
      </listitem>
      <listitem>
       <simpara>
    Constants may only evaluate to scalar values.
       </simpara>
      </listitem>
     </itemizedlist>
    </para>
    <para>
     The name of the constant is given by <parameter>name</parameter>;
     the value is given by <parameter>value</parameter>.
    </para>
    <para>
     The optional third parameter
     <parameter>case_insensitive</parameter> is also available. If the
     value <emphasis>1</emphasis> is given, then the constant will be
     defined case-insensitive. The default behaviour is
     case-sensitive; i.e. CONSTANT and Constant represent different
     values.
    </para>
    <para>
     <example>
      <title>Defining Constants</title>
      <programlisting role="php">
<?php
define ("CONSTANT", "Hello world.");
echo CONSTANT; // outputs "Hello world."
?>
      </programlisting>
     </example>
    </para>
    <para>
     <function>define</function> returns &true; on success and &false; if
     an error occurs.
    </para>
    <para>
     See also <function>defined</function> and the section on <link
     linkend="language.constants">Constants</link>.
    </para>
   </refsect1>
  </refentry>
  <refentry id="function.defined">
   <refnamediv>
    <refname>defined</refname>
    <refpurpose>
     Checks whether a given named constant exists
    </refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>int</type><methodname>defined</methodname>
      <methodparam><type>string</type><parameter>name</parameter></methodparam>
     </methodsynopsis>
    <para>
     Returns &true; if the named constant given by
     <parameter>name</parameter> has been defined, &false; otherwise.
      <example>
      <title>Checking Constants</title>
      <programlisting role="php">
<?php
if (defined("CONSTANT")){ // Note that it should be quoted
    echo CONSTANT; //
    }
?>
      </programlisting>
     </example>
    </para>
    <para>
     See also <function>define</function> and the section on <link
     linkend="language.constants">Constants</link>.
    </para>
   </refsect1>
  </refentry>
  <refentry id="function.die">
   <refnamediv>
    <refname>die</refname>
    <refpurpose>
     Output a message and terminate the current script
    </refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>void</type><methodname>die</methodname>
      <methodparam><type>string</type><parameter>message</parameter></methodparam>
     </methodsynopsis>
    <simpara>
     This language construct outputs a message and terminates parsing
     of the script.  It does not return anything.
    </simpara>
    <para>
     <example>
      <title>die example</title>
      <programlisting role="php">
<?php
$filename = '/path/to/data-file';
$file = fopen ($filename, 'r')
    or die("unable to open file ($filename)");
?>
      </programlisting>
     </example>
    </para>
    <simpara>
     See also <function>exit</function>.
    </simpara>
   </refsect1>
  </refentry>
  <refentry id="function.eval">
   <refnamediv>
    <refname>eval</refname>
    <refpurpose>Evaluate a string as PHP code</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>mixed</type><methodname>eval</methodname>
      <methodparam><type>string</type><parameter>code_str</parameter></methodparam>
     </methodsynopsis>
    <simpara>
     <function>eval</function> evaluates the string given in
     <parameter>code_str</parameter> as PHP code. Among other things,
     this can be useful for storing code in a database text field for
     later execution.
    </simpara>
    <simpara>
     There are some factors to keep in mind when using
     <function>eval</function>. Remember that the string passed must
     be valid PHP code, including things like terminating statements
     with a semicolon so the parser doesn't die on the line after the
     <function>eval</function>, and properly escaping things in
     <parameter>code_str</parameter>.
    </simpara> 
    <simpara>
     Also remember that variables given values under
     <function>eval</function> will retain these values in the main
     script afterwards.
    </simpara>
    <simpara>
     A <literal>return</literal> statement will terminate the evaluation of 
     the string immediatley. In PHP 4 you may use <literal>return</literal>
     to return a value that will become the result of the 
     <function>eval</function> function while in PHP 3 
     <function>eval</function> was of type <literal>void</literal> and did 
     never return anything.
    </simpara>
    <para>
     <example>
      <title>
       <function>eval</function> example - simple text merge
      </title>
      <programlisting role="php">
<?php
$string = 'cup';
$name = 'coffee';
$str = 'This is a $string with my $name in it.<br>';
echo $str;
eval ("\$str = \"$str\";");
echo $str;
?>
      </programlisting>
     </example>
    </para>
    <para>
     The above example will show:
     <programlisting>
This is a $string with my $name in it.
This is a cup with my coffee in it.
     </programlisting>
    </para>
   </refsect1>
  </refentry>
  <refentry id="function.exit">
   <refnamediv>
    <refname>exit</refname>
    <refpurpose>Terminate current script</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>void</type><methodname>exit</methodname>
      <void/>
     </methodsynopsis>
    <simpara>
     This language construct terminates parsing of the script.    It
     does not return.
    </simpara>
    <simpara>
     See also <function>die</function>.
    </simpara>
   </refsect1>
  </refentry> 
  <refentry id="function.get-browser">
   <refnamediv>
    <refname>get_browser</refname>
    <refpurpose>
     Tells what the user's browser is capable of
    </refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>object</type><methodname>get_browser</methodname>
      <methodparam choice="opt"><type>string</type><parameter>user_agent</parameter></methodparam>
     </methodsynopsis>
    <simpara>
     <function>get_browser</function> attempts to determine the
     capabilities of the user's browser. This is done by looking up
     the browser's information in the
     <filename>browscap.ini</filename> file. By default, the value of
     $HTTP_USER_AGENT is used; however, you can alter this (i.e., look
     up another browser's info) by passing the optional
     <parameter>user_agent</parameter> parameter to
     <function>get_browser</function>.
    </simpara>
    <simpara>
     The information is returned in an object, which will contain
     various data elements representing, for instance, the browser's
     major and minor version numbers and ID string; &true;/false values
     for features such as frames, JavaScript, and cookies; and so
     forth.
    </simpara>
    <simpara>
     While <filename>browscap.ini</filename> contains information on
     many browsers, it relies on user updates to keep the database
     current. The format of the file is fairly self-explanatory.
    </simpara>
    <para>
     The following example shows how one might list all available
     information retrieved about the user's browser.
     <example>
      <title><function>get_browser</function> example</title>
      <programlisting role="php">
<?php
function list_array ($array) {
    while (list ($key, $value) = each ($array)) {
    $str .= "<b>$key:</b> $value<br>\n";
    }
    return $str;
}
echo "$HTTP_USER_AGENT<hr>\n";
$browser = get_browser();
echo list_array ((array) $browser);
?>
      </programlisting>
     </example>
    </para>
    <simpara>
     The output of the above script would look something like this:
    </simpara>
    <programlisting>
Mozilla/4.5 [en] (X11; U; Linux 2.2.9 i586)<hr>
<b>browser_name_pattern:</b> Mozilla/4\.5.*<br>
<b>parent:</b> Netscape 4.0<br>
<b>platform:</b> Unknown<br>
<b>majorver:</b> 4<br>
<b>minorver:</b> 5<br>
<b>browser:</b> Netscape<br>
<b>version:</b> 4<br>
<b>frames:</b> 1<br>
<b>tables:</b> 1<br>
<b>cookies:</b> 1<br>
<b>backgroundsounds:</b> <br>
<b>vbscript:</b> <br>
<b>javascript:</b> 1<br>
<b>javaapplets:</b> 1<br>
<b>activexcontrols:</b> <br>
<b>beta:</b> <br>
<b>crawler:</b> <br>
<b>authenticodeupdate:</b> <br>
<b>msn:</b> <br>
    </programlisting>
    <simpara>
     In order for this to work, your <link
     linkend="ini.sect.browscap">browscap</link> configuration file
     setting must point to the correct location of the
     <filename>browscap.ini</filename> file.
    </simpara>
    <simpara>
     For more information (including locations from which you may
     obtain a <filename>browscap.ini</filename> file), check the PHP
     FAQ at <ulink
     url="&url.php.faq;">&url.php.faq;</ulink>.
    </simpara>
   </refsect1>
  </refentry>
  <refentry id="function.highlight-file">
   <refnamediv>
    <refname>highlight_file</refname>
    <refpurpose>Syntax highlighting of a file</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>boolean</type><methodname>highlight_file</methodname>
      <methodparam><type>string</type><parameter>filename</parameter></methodparam>
     </methodsynopsis>
    <simpara>
     The <function>highlight_file</function> function prints out a syntax
     higlighted version of the code contained in <parameter>filename</parameter> 
     using the colors defined in the built-in syntax highlighter for PHP.
     It returns &true; on success, &false; otherwise (PHP 4).
    </simpara>
   <para>
     <example>
      <title>Creating a source highlighting URL</title>
      <simpara>
       To setup a URL that can code hightlight any script that you pass to
       it, we will make use of the "ForceType" directive in
       Apache to generate a nice URL pattern, and use the 
       function <function>highlight_file</function> to show a nice looking
       code list.
      </simpara>
      <simpara>
       In your httpd.conf you can add the following:
      </simpara>
      <para>
       <informalexample><programlisting>
<Location /source>
    ForceType application/x-httpd-php
</Location>
       </programlisting></informalexample>
      </para>
      <simpara>
       And then make a file named "source" and put it in your
       web root directory.
      </simpara>
      <para>
       <programlisting role="php">
<HTML>
<HEAD>
<TITLE>Source Display</TITLE>
</HEAD>
<BODY BGCOLOR="white">
<?php
    $script = getenv ("PATH_TRANSLATED");
    if(!$script) {
    echo "<BR><B>ERROR: Script Name needed</B><BR>";
    } else {
    if (ereg("(\.php|\.inc)$",$script)) {
    echo "<H1>Source of: $PATH_INFO</H1>\n<HR>\n";
    highlight_file($script);
    } else {
    echo "<H1>ERROR: Only PHP or include script names are allowed</H1>"; 
    }
    }
    echo "<HR>Processed: ".date("Y/M/d H:i:s",time());
?>
</BODY>
</HTML>
       </programlisting>
      </para>
      <simpara>
       Then you can use an URL like the one below to display a colorized
       version of a script located in "/path/to/script.php" 
       in your web site.
      </simpara>
      <para>
       <informalexample>
    <programlisting>
http://your.server.com/source/path/to/script.php
    </programlisting>
       </informalexample>
      </para>
     </example>
    </para>
    <simpara>
     See also <function>highlight_string</function>,
     <function>show_source</function>.
    </simpara>
   </refsect1>
  </refentry>
  <refentry id="function.highlight-string">
   <refnamediv>
    <refname>highlight_string</refname>
    <refpurpose>Syntax highlighting of a string</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>void</type><methodname>highlight_string</methodname>
      <methodparam><type>string</type><parameter>str</parameter></methodparam>
     </methodsynopsis>
    <simpara>
     The <function>highlight_string</function> function prints out a syntax
     highlighted version of <parameter>str</parameter> using the colors defined 
     in the built-in syntax highlighter for PHP.
     It returns &true; on success, &false; otherwise (PHP 4).
    </simpara>
    <simpara>
     See also <function>highlight_file</function>,
     <function>show_source</function>.
    </simpara>
   </refsect1>
  </refentry>
  <refentry id="function.ignore-user-abort">
   <refnamediv>
    <refname>ignore_user_abort</refname>
    <refpurpose>
     Set whether a client disconnect should abort script execution
    </refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>int</type><methodname>ignore_user_abort</methodname>
      <methodparam choice="opt"><type>int</type><parameter>setting</parameter></methodparam>
     </methodsynopsis>
    <simpara>
     This function sets whether a client disconnect should cause a
     script to be aborted.    It will return the previous setting and
     can be called without an argument to not change the current
     setting and only return the current setting.  See the <link
     linkend="features.connection-handling">Connection Handling</link>
     section in the <link linkend="features">Features</link> chapter
     for a complete description of connection handling in PHP.
    </simpara>
   </refsect1>
  </refentry> 
    
  <refentry id="function.iptcparse">
   <refnamediv>
    <refname>iptcparse</refname>
    <refpurpose>
     Parse a binary IPTC <ulink url="&url.iptc;">&url.iptc;</ulink>
     block into single tags.
    </refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>array</type><methodname>iptcparse</methodname>
      <methodparam><type>string</type><parameter>iptcblock</parameter></methodparam>
     </methodsynopsis>
    <simpara>
     This function parses a binary IPTC block into its single tags. It
     returns an array using the tagmarker as an index and the value as
     the value. It returns &false; on error or if no IPTC data was
     found.  See <function>GetImageSize</function> for a sample.
    </simpara>
   </refsect1>
  </refentry>
  <refentry id="function.leak">
   <refnamediv>
    <refname>leak</refname>
    <refpurpose>Leak memory</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>void</type><methodname>leak</methodname>
      <methodparam><type>int</type><parameter>bytes</parameter></methodparam>
     </methodsynopsis>
    <simpara>
     <function>leak</function> leaks the specified amount of memory.
    </simpara>
    <simpara>
     This is useful when debugging the memory manager, which
     automatically cleans up "leaked" memory when each request is
     completed.
    </simpara>
   </refsect1>
  </refentry>
  <refentry id="function.pack">
   <refnamediv>
    <refname>pack</refname>
    <refpurpose>Pack data into binary string.</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>string</type><methodname>pack</methodname>
      <methodparam><type>string</type><parameter>format</parameter></methodparam>
      <methodparam choice="opt"><type>mixed</type><parameter>args</parameter></methodparam>
     </methodsynopsis>
    <para>
     Pack given arguments into binary string according to
     <parameter>format</parameter>. Returns binary string containing
     data.
    </para>
    <para>
     The idea to this function was taken from Perl and all formatting
     codes work the same as there, however, there are some formatting
     codes that are missing such as Perl's "u" format code. The format
     string consists of format codes followed by an optional repeater
     argument. The repeater argument can be either an integer value or
     * for repeating to the end of the input data. For a, A, h, H the
     repeat count specifies how many characters of one data argument
     are taken, for @ it is the absolute position where to put the
     next data, for everything else the repeat count specifies how
     many data arguments are consumed and packed into the resulting
     binary string. Currently implemented are
     <itemizedlist>
      <listitem>
       <simpara>
    a NUL-padded string
       </simpara>
      </listitem>
      <listitem>
       <simpara>
    A SPACE-padded string
       </simpara>
      </listitem>
      <listitem>
       <simpara>
    h Hex string, low nibble first
       </simpara>
      </listitem>
      <listitem>
       <simpara>
    H Hex string, high nibble first
       </simpara>
      </listitem>
      <listitem>
       <simpara>
    c signed char
       </simpara>
      </listitem>
      <listitem>
       <simpara>
    C unsigned char
       </simpara>
      </listitem>
      <listitem>
       <simpara>
    s signed short (always 16 bit, machine byte order)
       </simpara>
      </listitem>
      <listitem>
       <simpara>
    S unsigned short (always 16 bit, machine byte order)
       </simpara>
      </listitem>
      <listitem>
       <simpara>
    n unsigned short (always 16 bit, big endian byte order)
       </simpara>
      </listitem>
      <listitem>
       <simpara>
    v unsigned short (always 16 bit, little endian byte order)
       </simpara>
      </listitem>
      <listitem>
       <simpara>
    i signed integer (machine dependent size and byte order)
       </simpara>
      </listitem>
      <listitem>
       <simpara>
    I unsigned integer (machine dependent size and byte order)
       </simpara>
      </listitem>
      <listitem>
       <simpara>
    l signed long (always 32 bit, machine byte order)
       </simpara>
      </listitem>
      <listitem>
       <simpara>
    L unsigned long (always 32 bit, machine byte order)
       </simpara>
      </listitem>
      <listitem>
       <simpara>
    N unsigned long (always 32 bit, big endian byte order)
       </simpara>
      </listitem>
      <listitem>
       <simpara>
    V unsigned long (always 32 bit, little endian byte order)
       </simpara>
      </listitem>
      <listitem>
       <simpara>
    f float (machine dependent size and representation)
       </simpara>
      </listitem>
      <listitem>
       <simpara>
    d double (machine dependent size and representation)
       </simpara>
      </listitem>
      <listitem>
       <simpara>
    x NUL byte
       </simpara>
      </listitem>
      <listitem>
       <simpara>
    X Back up one byte
       </simpara>
      </listitem>
      <listitem>
       <simpara>
    @ NUL-fill to absolute position
       </simpara>
      </listitem>
     </itemizedlist>
     <example>
      <title><function>pack</function> format string</title>
      <programlisting role="php">
$binarydata = pack ("nvc*", 0x1234, 0x5678, 65, 66);
      </programlisting>
      <para>
       The resulting binary string will be 6 bytes long and contain
       the byte sequence 0x12, 0x34, 0x78, 0x56, 0x41, 0x42.
      </para>
     </example>
    </para>
    <para>
     Note that the distinction between signed and unsigned values only 
     affects the function <function>unpack</function>, where as
     function <function>pack</function> gives the same result for
     signed and unsigned format codes.
    </para>
    <para>
     Also note that PHP internally stores integral values as signed
     values of a machine dependent size. If you give it an unsigned
     integral value too large to be stored that way it is converted to
     a double which often yields an undesired result.
    </para>
   </refsect1>
  </refentry>
  <refentry id="function.show-source">
   <refnamediv>
    <refname>show_source</refname>
    <refpurpose>Syntax highlighting of a file</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>boolean</type><methodname>show_source</methodname>
      <methodparam><type>string</type><parameter>filename</parameter></methodparam>
     </methodsynopsis>
    <simpara>
     The <function>show_source</function> function prints out a syntax
     higlighted version of the code contained in <parameter>filename</parameter> 
     using the colors defined in the built-in syntax highlighter for PHP.
     It returns &true; on success, &false; otherwise (PHP 4).
    </simpara>
    <note>
     <simpara>
      This function is an alias for the function
      <function>highlight_file</function>
     </simpara>
    </note>
    <simpara>
     See also <function>highlight_string</function>,
     <function>highlight_file</function>.
    </simpara>
   </refsect1>
  </refentry>
  <refentry id="function.sleep">
   <refnamediv>
    <refname>sleep</refname>
    <refpurpose>Delay execution</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>void</type><methodname>sleep</methodname>
      <methodparam><type>int</type><parameter>seconds</parameter></methodparam>
     </methodsynopsis>
    <simpara>
     The sleep function delays program execution for the given number
     of <parameter>seconds</parameter>.
    </simpara>
    <simpara>
     See also <function>usleep</function>.
    </simpara>
   </refsect1>
  </refentry>
  <refentry id="function.uniqid">
   <refnamediv>
    <refname>uniqid</refname>
    <refpurpose>Generate a unique id</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>int</type><methodname>uniqid</methodname>
      <methodparam><type>string</type><parameter>prefix</parameter></methodparam>
      <methodparam choice="opt"><type>boolean</type><parameter>lcg</parameter></methodparam>
     </methodsynopsis>
    <simpara>
     <function>uniqid</function> returns a prefixed unique identifier
     based on the current time in microseconds. The prefix can be
     useful for instance if you generate identifiers simultaneously on
     several hosts that might happen to generate the identifier at the
     same microsecond.    <parameter>Prefix</parameter> can be up to 114
     characters long.
    </simpara>
    <simpara>
     If the optional <parameter>lcg</parameter> parameter is &true;,
     <function>uniqid</function> will add additional "combined LCG"
     entropy at the end of the return value, which should make the
     results more unique.
    </simpara>
    <simpara>
     With an empty <parameter>prefix</parameter>, the returned string
     will be 13 characters long.  If <parameter>lcg</parameter> is
     &true;, it will be 23 characters.
    </simpara>
    <note>
     <simpara>
      The <parameter>lcg</parameter> parameter is only available in
      PHP 4 and PHP 3.0.13 and later.
     </simpara>
    </note>
    <para>
     If you need a unique identifier or token and you intend to give
     out that token to the user via the network (i.e. session cookies),
     it is recommended that you use something along the lines of
     <informalexample>
      <programlisting role="php">
$token = md5 (uniqid ("")); // no random portion
$better_token = md5 (uniqid (rand())); // better, difficult to guess
      </programlisting>
     </informalexample>
    </para>
    <simpara>
     This will create a 32 character identifier (a 128 bit hex number)
     that is extremely difficult to predict.
    </simpara>
   </refsect1>
  </refentry>
  <refentry id="function.unpack">
   <refnamediv>
    <refname>unpack</refname>
    <refpurpose>Unpack data from binary string</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>array</type><methodname>unpack</methodname>
      <methodparam><type>string</type><parameter>format</parameter></methodparam>
      <methodparam><type>string</type><parameter>data</parameter></methodparam>
     </methodsynopsis>
    <para>
     <function>unpack</function> from binary string into array
     according to <parameter>format</parameter>. Returns array
     containing unpacked elements of binary string.
    </para>
    <para>
     <function>unpack</function> works slightly different from Perl as
     the unpacked data is stored in an associative array. To
     accomplish this you have to name the different format codes and
     separate them by a slash /.
     <example>
      <title><function>unpack</function> format string</title>
      <programlisting role="php">
$array = unpack ("c2chars/nint", $binarydata);
      </programlisting>
      <para>
       The resulting array will contain the entries "chars1",
       "chars2" and "int".
      </para>
     </example>
    </para>
    <para>
     For an explanation of the format codes see also:
     <function>pack</function>
    </para>
    <para>
     Note that PHP internally stores integral values as signed. If you
     unpack a large unsigned long and it is of the same size as PHP
     internally stored values the result will be a negative number
     even though unsigned unpacking was specified.
    </para>
   </refsect1>
  </refentry>
  <refentry id="function.usleep">
   <refnamediv>
    <refname>usleep</refname>
    <refpurpose>Delay execution in microseconds</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>void</type><methodname>usleep</methodname>
      <methodparam><type>int</type><parameter>micro_seconds</parameter></methodparam>
     </methodsynopsis>
    <simpara>
     The <function>usleep</function> function delays program execution
     for the given number of <parameter>micro_seconds</parameter>.
    </simpara>
    <simpara>
     See also <function>sleep</function>.
    </simpara>
    <note>
     <simpara>
      This function does not work on Windows systems.
     </simpara>
    </note>
   </refsect1>
  </refentry>
 </reference>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->
 |