-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphp-functions-doc
More file actions
2877 lines (2129 loc) · 113 KB
/
php-functions-doc
File metadata and controls
2877 lines (2129 loc) · 113 KB
1
2
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
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Abs(arg)
Abs returns the absolute value of arg.
Ada_Close(connection_id)
Ada_Close will close down the connection to the Adabas server
associated with the given connection identifier.
This function is only available if Adabas support has been enabled in
PHP.
Ada_Connect(data source name, username, password)
Ada_Connect opens a connection to a Adabas server. Each of the
arguments should be a quoted string. The first parameter (data source
name) is a string in the form "servername:databasename". The servername
(but not the colon) can be omitted if you want to access a local
database. This function returns a connection_id. This identifier is
needed by other Adabas functions. You can have multiple connections
open at once. This function will return 0 on error.
This function is only available if Adabas support has been enabled in
PHP.
Ada_Exec(connection_id, query_string)
Ada_Exec will send an SQL statement to the Adabas server specified by
the connection_id. The connection_id must be a valid identifier that
was returned by Ada_Connect or the special value 0. If connection_id is
0, ada_exec tries to establish or to use a connection with the
parameters given with the configuration directives phpAdaDefDB,
phpAdaUser and phpAdaPW.
The return value of this function is an identifier to be used to access
the results by other Adabas functions. This function will return 0 on
error. It will return 1 when the command executed correctly but is not
expected to return data (insert or update commands, for example). Note
that selects which return no data will still return a valid result
greater than 1.
This function is only available if Adabas support has been enabled in
PHP.
Ada_FetchRow(result_id [,row_number])
Ada_FetchRow fetches a row of the data that was returned by Ada_Exec.
After Ada_FetchRow is called, the fields of that row can be access with
Ada_Result. If no rownumber is given, Ada_FetchRow will try to fetch
the next row in the result set. Every time Ada_FetchRow is called a new
row can be accessed by Ada_Result. If Ada_FetchRow was succesful (there
was a row), 1 is returned, if there are no more rows, Ada_FetchRow will
return 0. The return value of Ada_FetchRow can be used as the condition
of a while loop. Calls to Ada_FetchRow() with and without rownumber can
be mixed. To step through the result more than once, you can call
Ada_FetchRow() with rownumber 1 and then continue with Ada_FetchRow()
without rownumber to review the result.
This function is only available if Adabas support has been enabled in
PHP.
Ada_FieldName(result_id, field_number)
Ada_FieldName will return the name of the field occupying the given
column number in the given Adabas result identifier. Field numbering
starts from 0.
This function is only available if Adabas support has been enabled in
PHP.
Ada_FieldNum(result_id, field_name)
Ada_FieldNum will return the number of the column slot that corresponds
to the named field in the given Adabas result identifier. Field
numbering starts at 0. This function will return -1 on error.
This function is only available if Adabas support has been enabled in
PHP.
Ada_FieldType(result_id, field_name|field_number)
Ada_FieldType will return the SQL type of the field referecend by name
or number in the given Adabas result identifier. Note: Field numbering
starts from 0.
This function is only available if Adabas support has been enabled in
PHP.
Ada_FreeResult(result_id)
Ada_FreeResult only needs to be called if you are worried about using
too much memory while your script is running. All result memory will
automatically be freed when the script is finished. But, if you are
sure you are not going to need the result data anymore in a script, you
may call Ada_FreeResult with the result identifier as an argument and
the associated result memory will be freed.
This function is only available if Adabas support has been enabled in
PHP.
Ada_NumFields(result_id)
Ada_NumFields will return the number of fields (columns) in a Adabas
result. The argument is a valid result identifier returned by Ada_Exec.
This function will return -1 on error.
This function is only available if Adabas support has been enabled in
PHP.
Ada_NumRows(result_id)
Ada_NumRows will return the number of rows in a Adabas result. The
argument is a valid result identifier returned by Ada_Exec. This
function will return -1 on error. For INSERT, UPDATE, DELETE statements
Ada_NumRows() returns the number of rows affected. For a SELECT clause
this is the number of rows available.
This function is only available if Adabas support has been enabled in
PHP.
Ada_Result(result_id, field name | index)
Ada_Result will return values from a result identifier produced by
Ada_Exec. The field name specify what cell in the row to return.
Instead of naming the field, you may use the field index as an unquoted
number. Field indices start from 0. If the requested field is of code
type BYTE (binary) or is longer than 4096 bytes, the contents is sent
directly to the client. Hint: [VAR]CHAR BYTE fields can be returned
into a php variable by using the HEX() db function; e. g. SELECT
HEX(SYSKEY) SYSKEY FROM MYTABLE.
This function is only available if Adabas support has been enabled in
PHP.
Ada_ResultAll(result_id [,format])
Ada_ResultAll will print all rows from a result identifier produced by
Ada_Exec. The result is printed in HTML table format. With the optional
formatstring additional overall table formatting can be done (e. g.
bgcolor= will set background color, >caption> </caption to set
caption). Note: The contents of "format" will be inserted into the HTML
table tag like this <table format >...
This function is only available if Adabas support has been enabled in
PHP.
AddSlashes(arg)
Escapes any $ \ or ' (if MAGIC_QUOTES is set) with a backslash. See
also StripSlashes().
ASort(array)
Sort is used to sort a PHP associative array in ascending order. Use
ARSort() for descending order. Unlike the Sort() function, ASort()
maintains index-value pairings. It understands the three variable types
and will sort alphabetically if the array contains strings, and
numerically if the array contains numbers. In the case of an array
which contains a mixture of types, the first type in the array will
specify the sort method. Note that if you are going to sort a
non-associative array, you should use the Sort() function.
BinDec(binary_string)
BinDec returns the decimal equivalent of the binary number represented
by the binary_string argument. The largest number that can be converted
is 31 bits long or 4294967295 in decimal. See also the DecBin()
function.
Ceil(value)
Ceil() rounds a floating point value up to the next integer. The return
value is of type double (floating point) such that it can be used
properly in complex equations. To get an integer type back, use: $new =
IntVal(Ceil($value));
See also Floor().
ChDir(dir)
ChDir changes the current working directory to the directory specified
in the argument.
ChGrp(file,group)
ChGrp changes the group id of the specified file.
ChMod(file,perms)
ChMod changes the file permissions of the specified file. The perms
parameter must be specified in octal notation. eg.
ChMod($filename,0755)
ChOwn(file,owner)
ChOwn changes the specified file to be owned by the specified owner.
Note that this will only work if the PHP/FI binary is running as root
(which is not generally a good idea).
Chop(string)
Chop removes all trailing whitespaces including new-lines, tabs and
spaces and returns the new string.
Chr(arg)
Chr returns the ASCII character represented by the integer argument.
ClearStack()
The ClearStack() function is a hack/workaround for a deficiency in the
PHP parser. This dificiency is that PHP only has a single expression
stack. When inside a user-defined function this expression stack is
never cleared because its contents may be needed within a complex
expression in the context from which the user-defined function was
called. This means that if you have a while loop with a lot of
iterations inside a user-defined function, you may be chewing up a lot
of stack space. You may even be hitting the max data space limit. You
can put a call to ClearStack() inside your while loop to prevent this
memory consumption, but the trade-off is that you cannot use your
function within any sort of context. ie. you have to assign the output
of the function to a temporary variable and then use this temporary
variable in whatever context you need.
ClearStatCache()
The stat() system call is normally an expensive operation on most
operating systems. In order to make sure that repeated calls to the
various File* functions like FilePerms(), FileInode(), etc. the result
of the last stat() call is always cached. If one of the File* functions
is called again with the same argument, the cached stat() result will
be used. In order to force a new stat() system call this
ClearStatCache() function may be called to clear the cached stat()
result.
closeDir()
closeDir closes a directory opened using the openDir function.
CloseLog()
CloseLog() closes the descriptor Syslog() uses to write to the system
logger. See the closelog(3) UNIX man page for more details. See also
Syslog(), OpenLog() and InitSyslog().
Cos(arg)
Cos returns the cosine of arg in radians. See also Sin() and Tan()
Count(array)
Count returns the number of items in an array variable. If the variable
is not an array, the return value will be 1 (because a normal variable
is similar to an array with only one item). If the variable is not
defined, the return value will be 0.
Crypt(string,[salt])
Crypt will encrypt a string using the standard Unix DES encryption
method. Arguments are a string to be encrypted and an optional
two-character salt string to base the encryption on. See the Unix man
page for your crypt function for more information. If you do not have a
crypt function on your Unix system, you can use Michael Glad's public
domain UFC-Crypt package which was developed in Denmark and hence not
restricted by US export laws as long as you ftp it from an non-US site.
Date(format,time)
The Date function is used to display times and dates in various ways.
The function takes a format string and a time as arguments. If the time
argument is left off, the current time and date will be used. The time
argument is specified as an integer in number of seconds since the Unix
Epoch on Jan.1 1970. The format string is used to indicate which
date/time components should be displayed and how they should be
formatted. The following characters are recognized within the format
string. Any unrecognized character is printed verbosely:
o Y - Year eg. 1995
o y - Year eg. 95
o M - Month eg. Oct
o m - Month eg. 10
o F - Month eg. October
o D - Day eg. Fri
o l - Day eg. Friday
o d - Day eg. 27
o z - Day of the year eg. 299
o H - Hours in 24 hour format eg. 13
o h - Hours in 12 hour format eg. 1
o i - Minutes eg. 5
o s - Seconds eg. 40
o U - Seconds since epoch eg. 814807830
o A - AM/PM
o a - am/pm
See also the MkTime() function.
dbList()
dbList outputs information about the db support compiled into PHP.
dbmClose(filename)
dbmClose simply closes the specified dbm file. It will also unlock any
lock files, so it is important to close any dbm files that have been
opened.
dbmDelete(filename,key)
dbmDelete will delete the key/content pair specified by the given key
argument.
dbmExists(filename,key)
dbmExists will return 1 if the key exists and 0 otherwise.
dbmFetch(filename,key)
dbmFetch will return the content string associated with the given key.
dbmFirstKey(filename)
dbmFirstKey returns the first key in the dbm file. Note that no
particular order is guaranteed since the order depends on hash table
values calculated within the dbm implementation. You may use the Sort
function to sort arrays of data from the dbm file if necessary.
dbmInsert(filename,key,content)
dbmInsert inserts a new key/content data pair into a dbm file. If the
key already exists, the insert will fail.
dbmNextKey(filename,key)
dbmNextKey returns the next key after the specified key. By calling
dbmfirstkey() followed by successive calls to dbmnextkey() it is
possible to visit every key/content pair in the dbm file.
dbmOpen(filename,mode)
dbmOpen() opens a dbm file. The first argument is the full-path
filename of the dbm file to be opened and the second is the file open
mode which is one of "r", "n" or "w" for read, new (implies write) and
write respectively. If ndbm support is used, ndbm will actually create
filename.dir and filename.pag files. gdbm only uses one file, as does
the internal flat ascii file support, and Berkeley's libdb create a
filename.db file. Note that PHP does its own file locking in addition
to any file locking that may be done by the dbm library itself. PHP
does not delete the .lck files it creates. It uses these files simply
as fixed inodes on which to do the file locking. For more information
on dbm files, see your Unix man pages, or obtain GNU's gdbm from
ftp://prep.ai.mit.edu/pub/gnu.
dbmReplace(filename,key,content)
dbmReplace is similar to the dbminsert() function, the only difference
being that if the key already exists, the old content string will be
replaced with the new.
DecBin(number)
DecBin returns a string containing a binary representation of the given
number argument. The largest number that can be converted is 31 bits
long or 4294967295 in decimal. See also the BinDec() function.
DecHex(number)
DecHex converts a decimal number to a hexadecimal string. See also the
HexDec() function.
DecOct(number)
DecOct converts a decimal number to an octal number. See also OctDec().
doubleval(variable)
doubleval returns the double (floating point) value of the variable.
See also the strval() and intval() functions.
Echo [format_string] expression [, expression [,...]]
Echo is not a function. ie. you do not put brackets around the
arguments to it. It is used to display results of PHP functions or PHP
variables. See the Escape Character Section for a list of special
characters supported. The format_string is optional and if not present,
no output formatting will be done. The format string is similar to the
format string of the C printf function. See the man page for printf for
more details. Up to 5 expressions can be printed with a single echo
command. If you try to print more you will get a parser error. Note
that the types of the expressions are not relevant. The expressions are
automagically converted to the appropriate types as specified by the
format string if one is present. If you want to format something and
assign the formatted string to a variable instead of displaying it, use
the sprintf() function.
The following conversions are supported,
%d %i
Print a signed decimal number.
%o
Print an octal number.
%u
Print an unsigned decimal number.
%x %X
Print a hexadecimal number.
%f
Print a floating-point number.
%e %E
Print a floating-point number in scientific notation.
%g %G
Print a floating-point number in scientific notation or
normal notation, as appropriate.
%c
Print a single character.
%s
Print a string of characters.
%%
Print a literal percent-sign.
The following flags are accepted.
'-'
Left-justify the output within the field-width.
'+'
Ensure that all integers are signed (with a plus/minus
sign).
' '
Similar to '+', but uses a space instead of a plus-sign.
'#'
Print prefixes in front of hex and octal numbers
designating them as such.
'''
Separate the digits into groups (usually comma-separated
groups of three).
'0'
Pad the field-width with zeros.
All of these flags are dependent upon whether or not your C
library's printf function supports them (the ''', for
example, is a GNU extension).
Most conversions will accept a field width and a precision,
as shown in the demo_echo.html file in the directory
/examples. It is not necessary to specify any type modifiers,
and, in fact, PHP will complain if the type modifier does not
make sense (which is almost always the case). PHP will
complain about (and refuse to accept) anything that it does
not recognize. Any extra arguments given that are not
required by the format-string are ignored.
End(variable)
End moves the internal array pointer for the given variable to the last
item of the array and returns the value of this item. This is useful
for traversing an associative array in reverse order. See also Reset()
and Prev(). The following example would traverse an associative array
in reverse order:
<?
Reset($array);
$first_key = key($array);
End($array);
$k = key($array);
while($k != $first_key);
echo $array[$k];
prev($array);
$k = key($array);
endwhile;
echo $array[$k];
>
ereg(expr,arg[,regs])
ereg returns non-zero if the regular expression is matched in the
argument string. For example, the condition, <?if (ereg("^This.*",
"This is an example string")> would be true since the "^This.*"
expression says to match the word This at the beginning of the string
and then match any characters afterwards. If the regs argument is
present, then match registers are filled into positions 0-10 in the
array named by the regs argument. Register 0 will always contain the
full matched string. For more information on regular expressions, see
the regular expression section of this document.
eregi(expr,arg[,regs])
eregi is identical to the ereg() function except for the fact that the
regular expression is applied such that upper/lower case is ignored.
ereg_replace(expr,replace,arg)
ereg_Replace scans the entire argument string and replaces any portions
of the string matched by the given expression with the replacement
string. For example, in the string, "This is an example string" we
could very easily replace every space with a dash with the command:
ereg_replace(" ","-","This is an example string").For more information
on regular expressions, see the regular expression section of this
document.
eregi_replace(expr,replace,arg)
eregi_replace is identical to the ereg_replace() function except for
the fact that the regular expression is applied such that upper/lower
case is ignored.
EscapeShellCmd(string)
EscapeShellCmd escapes any characters in a string that might be used to
trick a shell command into executing arbitrary commands. This function
should be used to make sure that any data coming from user input is
escaped before this data is passed to the Exec() or System() functions.
A standard use would be:
<?system(EscapeShellCmd($cmd))>
Eval(string)
Eval takes the contents of the string argument and treats it like a
mini PHP/FI script. It will execute it as a separate PHP/FI script. Any
variables set or accessed from inside the eval will be from the global
reference frame in the current context of the eval statement in the
script. Variable substitution is done on the string arguments, so if
variables are to be used in the string expression they should be
escaped. Some examples:
$a = "echo phpversion();";
eval($a);
eval("echo phpversion();");
eval("\$a=1; echo \$a;");
Exec(command_string [, array [,return_var]])
Exec executes the given unix command, however it does not output
anything. It simply returns the last line from the result of the
command. If you need to execute a command and have all the data from
the command passed directly back without any interference, use the
PassThru() function. If the array argument is present, then the
specified array will be filled with every line of output from the unix
command starting at the end of the array. Make sure you UnSet the array
before the call if your array already contains elements and you want to
start filling it at array element 0. If the return_var argument is
present along with the array argument, then the return status of the
executed unix command will be written to this variable. Note that if
you are going to allow data coming from user input to be passed to this
Exec function, then you should be using the EscapeShellCmd() function
to make sure that users cannot trick the system into executing
arbitrary commands. See also the system() function.
Exit
The Exit command is used to terminate parsing right away as soon as
this tag is parsed.
Exp(arg)
Exp returns e raised to the power of arg. See also pow()
fclose($fd)
fclose() closes a file opened by fopen(). The argument is a file
pointer index as returned by the fopen() call.
feof($fd)
Feof returns true if the file referred to by the file pointer index
argument has hit end-of-file.
fgets($fd,bytes)
fgets() reads a line from a file opened by fopen(). Arguments are a
file pointer index as returned by fopen() and the max number of bytes
to read. Reading ends when max number of bytes have been read, or on an
end of line. This is similar to the C fgets() call. See also fputs().
fgetss($fd,bytes)
Identical to the fgets() function, except this one tries to strip off
any HTML tags or PHP/FI script tags as it is reading the file.
File(filename)
File reads the entire file and returns an array with each array element
containing a line of the file starting with array index 0.
fileAtime(filename)
fileAtime returns the time of last data access. If the file does not
exist, or if it for some other reason could not be accessed, this
function returns -1. If repeated calls to fileAtime and the rest ofthe
file* functions are to be made and the file being accessed might change
or disappear, the ClearStatCache() should be called before the call to
the file* function.
fileCtime(filename)
fileCtime returns the time of last status change. If the file does not
exist, or if it for some other reason could not be accessed, this
function returns -1. If repeated calls to fileCtime and the rest ofthe
file* functions are to be made and the file being accessed might change
or disappear, the ClearStatCache() should be called before the call to
the file* function.
fileGroup(filename)
fileGroup returns the group id of the owner of the file. If the file
does not exist, or if it for some other reason could not be accessed,
this function returns -1. If repeated calls to fileGroup and the rest
ofthe file* functions are to be made and the file being accessed might
change or disappear, the ClearStatCache() should be called before the
call to the file* function.
fileInode(filename)
fileInode returns the file's inode. If the file does not exist, or if
it for some other reason could not be accessed, this function returns
-1. If repeated calls to fileInode and the rest ofthe file* functions
are to be made and the file being accessed might change or disappear,
the ClearStatCache() should be called before the call to the file*
function.
fileMtime(filename)
fileMtime returns the time of last data modification. If the file does
not exist, or if it for some other reason could not be accessed, this
function returns -1. If repeated calls to fileMtime and the rest ofthe
file* functions are to be made and the file being accessed might change
or disappear, the ClearStatCache() should be called before the call to
the file* function.
fileOwner(filename)
fileOwner returns the uid of the owner of the file. If the file does
not exist, or if it for some other reason could not be accessed, this
function returns -1. If repeated calls to fileOwner and the rest ofthe
file* functions are to be made and the file being accessed might change
or disappear, the ClearStatCache() should be called before the call to
the file* function.
filePerms(filename)
filePerms returns the permission bits of the file. This is the st_mode
field of the Unix C stat structure. If the file does not exist, or if
it for some other reason could not be accessed, this function returns
-1. If repeated calls to filePerms and the rest ofthe file* functions
are to be made and the file being accessed might change or disappear,
the ClearStatCache() should be called before the call to the file*
function.
fileSize(filename)
fileSize returns the size of the file in bytes. If the file does not
exist, or if it for some other reason could not be accessed, this
function returns -1. If repeated calls to fileSize and the rest ofthe
file* functions are to be made and the file being accessed might change
or disappear, the ClearStatCache() should be called before the call to
the file* function.
fileType(filename)
fileType returns the type of the file. The return values are one of:
"dir", "file","fifo","char", "block", or "link". These are for,
directory, regular file, fifo special, character special, block special
and symbolic link, respectively.
Floor(value)
Floor() rounds a floating point value down to the previous integer. The
return value is of type double (floating point) such that it can be
used properly in complex equations. To get an integer type back, use:
$new = IntVal(Floor($value));
See also Ceil().
Flush()
The Flush() function is used to Flush the output buffer. For the Apache
module, it flushes Apache's output buffer, and for the CGI version it
simply flushes stdout. When running as a CGI under Apache, the server
will buffer the CGI script's output, so this Flush() function won't
help much there. Look at running your script as an nph- script if you
are running the CGI version of PHP under the Apache web server. Or,
alternatively, run the Apache module version of PHP.
fopen(filename,mode)
fopen() opens a file and returns a file pointer index. If the file
could not be opened the function returns -1. It is similar to the C
fopen() call. The filename argument is the relative or absolute path to
the file to be opened, and the mode argument is one of, "r", "r+", "w",
"w+", "a", "a+". See the Unix man page on the fopen() call for more
information. See also the popen() function description. See also the
fclose() function description.
Example:
$fp = fopen("/home/rasmus/file.txt","r");
fputs(fp,string)
fputs() writes a line to a file opened by fopen(). Arguments are a file
pointer index as returned by fopen() and the string to write. Note that
the string argument may contain the special escape characters, \n, \r
and \t to output newlines, carriage returns and tabs respectively. See
also fgets().
FPassThru(fp)
FPassThru() outputs all remaining data on fp directly. It is different
from ReadFile() in that it can also handle files opened with
fsockopen(). It differs from PassThru() in that it does not handle
commands, but opened files. FPassThru() returns the number of bytes
read and written.
fseek(fp,pos)
fseek() positions a file pointer identified by the $fd argument which
is the return value of the fopen() call. The file pointer is positioned
at the beginning of the file plus the offset specified by the pos
argument. See also ftell() and rewind().
fsockopen(hostname,port)
fsockopen() opens a socket connection and returns a file pointer index.
This file pointer index can be used by fgets, fputs and fclose.
Arguments are a hostname and a port number. Return values are: -3 if
the socket couldn't be created, -4 if the dns lookup on the hostname
failed, -5 if the connection was refused or it timed out, -6 if the
actual fdopen() call failed or -7 if the setvbuf() call failed. If the
port number is 0, then the hostname argument will be treated as a
filename of a Unix domain socket if your operating system support Unix
domain sockets.
ftell(fp)
ftell() returns the position of a file pointer identified by the fp
argument which is the return value of the fopen() call. The position
can later be used as an argument to fseek(). See also fseek() and
rewind().
getAccDir()
getAccDir returns the directory where PHP access configuration files
are kept. The access configuration filenames come from the numerical
user id of the user whose access configurations they represent.
GetEnv(string)
GetEnv returns the value of the environment value specified by string.
Normally this function is not used because environment variables are
available to PHP/FI directly. If a reference is made to a variable
which is not found in the internal symbol table, then the environment
space is automatically searched. GetEnv should be used when it is
necessary to ensure that an environment variable has not been
overwritten by normal PHP/FI variable. Security mechanisms that rely on
http server-defined variables like REMOTE_ADDR and REMOTE_HOST should
load these variables using GetEnv as opposed to referencing them
directly as $REMOTE_ADDR to avoid someone making up a fake form and
posting the data to your server and thereby bypassing whatever security
mechanism you might have.
getHostByName(domain_name)
getHostByName converts the given domain name into an IP address in
nnn.nnn.nnn.nnn format.
getHostByAddr(ip_address)
getHostByAddr converts the given IP address in nnn.nnn.nnn.nnn format
into a fully qualified domain name.
GetImageSize(filename)
The GetImageSize() function takes either a full path filename, or a
relative path relative to the location of the calling script. It
returns a 3 element array consisting of width, height and type. Width
and height are in pixels, and a type of 1 means GIF, a 2 indicates a
JPG file and a 3 indicates a PNG file. Other file types are not
supported. The fourth element in the returned array is a string
containing, "width=x height=y" that is suitable for using directly in
an IMG tag. It is important to note that the GD image library is not
needed to use this function. An example follows:
<?
$result = GetImageSize("img/flag.jpg");
>
<IMG SRC="img/flag.jpg" ?echo $result[3]> >
getLastAccess()
getLastAccess returns the date and time in unix time format of the last
time the current page was access. This value can be passed to the
Date() function for formatting.
This function is only available if PHP was compiled with Access Logging
enabled.
getLastbrowser()
getLastBrowser returns the identification string of browser the last
user to access the current page used.
This function is only available if PHP was compiled with Access Logging
enabled.
getLastEmail()
getLastEmail returns the E-Mail address of the last user to access the
current page.
This function is only available if PHP was compiled with Access Logging
enabled.
getLastHost()
getLastHost returns the hostname of the last user to access the current
page.
This function is only available if PHP was compiled with Access Logging
enabled.
getLastMod()
getLastMod returns the date and time in unix time format of the last
time the current page was modified. This value can be passed to the
Date() function for formatting.
This function is only available if PHP was compiled with Access Logging
enabled.
getLastref()
getLastRef returns the URL of the referring document of the last user
to access the current page.
This function is only available if PHP was compiled with Access Logging
enabled.
getLogDir()
getLogDir returns the top-level directory under which PHP log files can
be found. The actual log files are in directories under this directory.
Each subdirectory is the numerical user id of the user to whom the log
files belong. Then within each directory a series of dbm log files are
found, each with the numerical inode of the file they represent as the
primary component of the filename.
getMyInode()
getMyInode returns the numerical inode of the current HTML file.
getMyPid()
getMyPid() returns the current process id of the PHP parsing process.
getMyUid()
getMyUid returns the numerical user id of the owner of the current HTML
file.
getRandMax()
getRandMax returns the maximum random number the Rand function will
return. If the value returned does not seem to be accurate, have a look
in the php.h source file in the PHP distribution for more information.
getStartLogging()
getStartLogging returns the time and date in Unix time format when
logging commenced on the current page. This is more accurate when
mSQL-based logging is used since a timestamp is kept in each log file.
For dbm-logging the time returned is the time the user's log directory
was created.
getToday()
getToday returns the total number of hits the current page has had
since 12 midnight local time.
This function is only available if PHP was compiled with Access Logging
enabled.
getTotal()
getTotal returns the total number of hits the current page has had
since access logging was started on the page.
This function is only available if PHP was compiled with Access Logging
enabled.
GetType(variable)
GetType returns the type of the variable. The return value is a string
and it is one of, "integer", "double" or "string". See also the
SetType() function
gmDate(format,time)
gmDate is identical to the Date function except for the fact that it
uses Greenwich Mean Time instead of the current local time.
Header(header_string)
The Header command is used at the top of an HTML file to send raw HTTP
header strings. See the HTTP Specification for more information on raw
http headers. Remember that the Header() command must be used before
any actual output is sent either by normal HTML tags or by PHP echo
commands.
Usage examples can be found in the HTTP Authentication section.
HexDec(hex_string)
HexDec converts a hexadecimal string to a decimal number. See also the
DecHex() function.
HtmlSpecialChars(string)
HtmlSpecialChars converts any characters with ascii codes in the string
argument between 160 and 255 inclusive to their corresponding HTML
Entity names. The function returns the converted string. The <, >, &
and " are also converted.
ImageArc(im, cx, cy, w, h, s, e, col)
ImageArc draws a partial ellipse centered at cx,cy (top left is 0,0) in
the image represented by im. w and h specifies the ellipse's width and
height respectively while the start and end points are specified in
degrees indicated by the s and e arguments.
This function is only available if GD support has been enabled in PHP.
ImageChar(im, size, x, y, c, col)
ImageChar draws the character c in the image identified by im at
coordinates x,y (top left is 0,0) in colour col. The size argument can
be 1, 2, 3, 4 or 5 indicating the size of the font to be used. 1 is the
smallest and 5 is the largest.
This function is only available if GD support has been enabled in PHP.
ImageCharUp(im, size, x, y, c, col)
ImageCharUp draws the character c vertically in the image identified by
im at coordinates x,y (top left is 0,0) in colour col. The size
argument can be 1, 2, 3, 4 or 5 indicating the size of the font to be
used. 1 is the smallest and 5 is the largest.
This function is only available if GD support has been enabled in PHP.
ImageColorAllocate(im, red, green, blue)
ImageColorAllocate returns a colour identifier representing the colour
composed of the given RGB components. The im argument is the return
from the ImageCreate function. ImageColorAllocate must be called to
create each colour that is to be used in the image represented by im.
This function is only available if GD support has been enabled in PHP.
ImageColorTransparent(im, col)
ImageColorTransparent sets the transparent colour in the im image to
col. im is the image identifier returned by ImageCreate and col is the
colour identifier returned by ImageColorAllocate. This function is only
available if GD support has been enabled in PHP.
ImageCopyResized(dst_im, src_im, dstX, dstY, srcX, srcY, dstW, dstH, srcW,
srcH )
ImageCopyResized copies a rectangular portion of one image to another
image. dst_im is the destination image, src_im is the source image
identifier. If the source and destination coordinates and width and
heights differ, appropriate stretching or shrinking of the image
fragment will be performed. The coordinates refer to the upper left
corner. This function can be used to copy regions within the same image
(if dst_im is the same as src_im) but if the regions overlap the
results will be unpredictable.
This function is only available if GD support has been enabled in PHP.
ImageCreate(x_size, y_size)
ImageCreate returns an image identifier representing a blank image of
size x_size by y_size.
This function is only available if GD support has been enabled in PHP.
ImageCreateFromGif(filename)
ImageCreateFromGif returns an image identifier representing the image
obtained from the given filename.
This function is only available if GD support has been enabled in PHP.
ImageDestroy(im)
ImageDestroy frees any memory associated with image im. im is the image
identifier returned by the ImageCreate function. This function is only
available if GD support has been enabled in PHP.
ImageFill(im, x, y, col)
ImageFill performs a flood fill starting at coordinate x,y (top left is
0,0) with colour col in image im.
This function is only available if GD support has been enabled in PHP.
ImageFilledPolygon(im, points, num_points, col)
ImageFilledPolygon creates a filled polygon in image im. points is a
PHP array containing the polygon's vertices. ie. points[0] = x0,
points[1] = y0, points[2] = x1, points[3] = y1, etc. num_points is the
total number of vertices.
This function is only available if GD support has been enabled in PHP.
ImageFilledRectangle(im, x1, y1, x2, y2, col)
ImageFilledRectangle creates a filled rectangle of colour col in image
im starting at upper left coordinate x1,y1 and ending at bottom right
coordinate x2,y2. 0,0 is the top left corner of the image.
This function is only available if GD support has been enabled in PHP.