├── test_php2python.py ├── setup.py ├── .gitignore ├── LICENSE ├── php2python.py └── README.md /test_php2python.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import php2python as p2py 3 | 4 | 5 | class Test(unittest.TestCase): 6 | 7 | def test_checkdate(self): 8 | pass 9 | 10 | 11 | if __name__ == '__main__': 12 | unittest.main() 13 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | 3 | setup(name='php2python', 4 | version='0.0.1', 5 | description='Python alternatives for PHP functions', 6 | url='https://github.com/jxlwqq/php2python', 7 | author='jxlwqq', 8 | author_email='jxlwqq@gmail.com', 9 | license='MIT', 10 | python_requires='>=3', 11 | requires=[ 12 | 'tzlocal>=1.5' 13 | ], 14 | zip_safe=False) 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.py[oc] 2 | 3 | # Temp files 4 | *~ 5 | ~* 6 | .*~ 7 | \#* 8 | .#* 9 | *# 10 | 11 | # Build files 12 | build 13 | dist 14 | pkg 15 | *.egg 16 | *.egg-info 17 | 18 | # Debian Files 19 | debian/files 20 | debian/python-beaver* 21 | 22 | # Sphinx build 23 | doc/_build 24 | 25 | # Generated man page 26 | doc/aws_hostname.1 27 | 28 | # tox 29 | .tox 30 | 31 | # Hypothesis - keep the examples database 32 | .hypothesis/tmp 33 | .hypothesis/unicodedata 34 | 35 | # py.test 36 | .cache/ 37 | 38 | # Pycharm 39 | .idea/ 40 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 金小龙(jxlwqq) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /php2python.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | # -*- coding: utf8 -*- 3 | 4 | from collections import Counter 5 | import random 6 | from functools import reduce 7 | import hashlib 8 | import locale 9 | import csv 10 | import io 11 | import re 12 | import math 13 | import time as py_time 14 | import datetime 15 | import binascii 16 | import urllib.parse 17 | import urllib.request 18 | from itertools import takewhile 19 | import numbers 20 | import pickle 21 | import pprint 22 | import base64 23 | import os 24 | import struct 25 | import sys 26 | import glob as py_glob 27 | import inspect 28 | import textwrap 29 | import crypt as py_crypt 30 | import quopri 31 | import string 32 | import syslog as py_syslog 33 | import fcntl 34 | import fnmatch as py_fnmatch 35 | import shutil 36 | import collections 37 | from socket import inet_ntoa 38 | from socket import inet_aton 39 | import socket 40 | from struct import pack 41 | from struct import unpack 42 | import http.cookies 43 | import codecs 44 | 45 | import tzlocal 46 | 47 | """ 48 | Array Functions 49 | """ 50 | 51 | 52 | def array_change_key_case(array, case=0): 53 | if case == 0: 54 | f = str.lower 55 | elif case == 1: 56 | f = str.upper 57 | else: 58 | raise ValueError() 59 | return dict((f(k), v) for k, v in array.items()) 60 | 61 | 62 | def array_chunk(array, size): 63 | return [array[i: i + size] for i in range(0, len(array), size)] 64 | 65 | 66 | def array_column(array, column_key, index_key=None): 67 | if index_key is None: 68 | return [item.get(column_key) for item in array] 69 | else: 70 | res = {} 71 | for item in array: 72 | res[item.get(index_key)] = item.get(column_key) 73 | return res 74 | 75 | 76 | def array_combine(keys, values): 77 | return dict(zip(keys, values)) 78 | 79 | 80 | def array_count_values(array): 81 | return Counter(array) 82 | 83 | 84 | def array_diff_assoc(): 85 | pass 86 | 87 | 88 | def array_diff_key(): 89 | pass 90 | 91 | 92 | def array_diff_uassoc(): 93 | pass 94 | 95 | 96 | def array_diff_ukey(): 97 | pass 98 | 99 | 100 | def array_diff(array1, array2): 101 | return list(set(array1).difference(array2)) 102 | 103 | 104 | def array_fill_keys(keys, value): 105 | return dict.fromkeys(keys, value) 106 | 107 | 108 | def array_fill(start_index, num, value): 109 | if start_index >= 0: 110 | keys = range(start_index, num + start_index) 111 | else: 112 | keys = [start_index] + list(range(0, num - 1)) 113 | return array_fill_keys(keys, value) 114 | 115 | 116 | def array_filter(array, callback=None): 117 | filter(callback, array) 118 | 119 | 120 | def array_flip(array): 121 | return dict((v, k) for k, v in array.items()) 122 | 123 | 124 | def array_intersect_assoc(array1, array2): 125 | pass 126 | 127 | 128 | def array_intersect_key(array1, *arrays): 129 | keys = array1.viewkeys() 130 | for array in arrays: 131 | keys &= array.viewkeys() 132 | return {k: array1[k] for k in keys} 133 | 134 | 135 | def array_intersect_uassoc(array1, array2, callback): 136 | pass 137 | 138 | 139 | def array_intersect_ukey(array1, array2, callback): 140 | pass 141 | 142 | 143 | def array_intersect(array1, array2): 144 | pass 145 | 146 | 147 | def array_key_exists(key, array): 148 | return key in array 149 | 150 | 151 | def array_key_first(array): 152 | return array.keys[0] 153 | 154 | 155 | def array_key_last(array): 156 | return array.keys[-1] 157 | 158 | 159 | def array_keys(array, search_value=None): 160 | if search_value is None: 161 | return array.keys() 162 | else: 163 | return [k for k, v in array.items() if v == search_value] 164 | 165 | 166 | def array_map(callback, array): 167 | return map(callback, array) 168 | 169 | 170 | def array_merge_recursive(array1, *arrays): 171 | for array in arrays: 172 | for key, value in array.items(): 173 | if key in array1: 174 | if isinstance(value, dict): 175 | array[key] = array_merge_recursive(array1[key], value) 176 | if isinstance(value, (list, tuple)): 177 | array[key] += array1[key] 178 | array1.update(array) 179 | return array1 180 | 181 | 182 | def array_merge(array1, array2): 183 | if isinstance(array1, list) and isinstance(array2, list): 184 | return array1 + array2 185 | elif isinstance(array1, dict) and isinstance(array2, dict): 186 | return dict(list(array1.items()) + list(array2.items())) 187 | elif isinstance(array1, set) and isinstance(array2, set): 188 | return array1.union(array2) 189 | return False 190 | 191 | 192 | def array_multisort(array): 193 | return sorted(array, key=lambda x: (x[1], x[2])) 194 | 195 | 196 | def array_pad(array, size, value): 197 | if size >= 0: 198 | return array + [value] * (size - len(array)) 199 | else: 200 | return [value] * (-size - len(array)) + array 201 | 202 | 203 | def array_pop(array): 204 | return array.pop() 205 | 206 | 207 | def array_product(array): 208 | if not array: 209 | return 0 210 | else: 211 | reduce(lambda a, b: a * b, array) 212 | 213 | 214 | def array_push(array, *values): 215 | for value in values: 216 | array.extend(value) 217 | 218 | 219 | def array_rand(array, num=1): 220 | if num == 1: 221 | return random.choice(array.keys()) 222 | else: 223 | return random.sample(array.keys(), num) 224 | 225 | 226 | def array_reduce(array, callback, initial=None): 227 | if initial is None: 228 | return reduce(callback, array) 229 | else: 230 | return reduce(function, array, initial) 231 | 232 | 233 | def array_replace_recursive(): 234 | pass 235 | 236 | 237 | def array_replace(): 238 | pass 239 | 240 | 241 | def array_reverse(array): 242 | return array[::-1] 243 | 244 | 245 | def array_search(needle, haystack, strict=False): 246 | pass 247 | 248 | 249 | def array_shift(array): 250 | return array.pop(0) 251 | 252 | 253 | def array_slice(array, offset, length=None): 254 | if is_array(array) and not isinstance(array, dict): 255 | if isinstance(array, set): 256 | array = list(array) 257 | return set(array[offset:length]) 258 | return array[offset:length] 259 | return False 260 | 261 | 262 | def array_splice(array, offset, length, replacement=None): 263 | if replacement is None: 264 | del array[offset: offset + length] 265 | else: 266 | array[offset: offset + length] = replacement 267 | return array 268 | 269 | 270 | def array_sum(array): 271 | return sum(array) 272 | 273 | 274 | def array_udiff_assoc(array): 275 | pass 276 | 277 | 278 | def array_udiff_uassoc(array): 279 | pass 280 | 281 | 282 | def array_udiff(array): 283 | pass 284 | 285 | 286 | def array_uintersect_assoc(array): 287 | pass 288 | 289 | 290 | def array_uintersect_uassoc(array): 291 | pass 292 | 293 | 294 | def array_uintersect(array): 295 | pass 296 | 297 | 298 | def array_unique(array): 299 | return list(set(array)) 300 | 301 | 302 | def array_unshift(array, *args): 303 | for i in reversed(args): 304 | array.insert(0, i) 305 | return array 306 | 307 | 308 | def array_values(array): 309 | return array.values() 310 | 311 | 312 | def array_walk_recursive(array): 313 | pass 314 | 315 | 316 | def array_walk(array, callback): 317 | for k, val in array.items(): 318 | callback(val, k) 319 | 320 | 321 | def array(array): 322 | pass 323 | 324 | 325 | def arsort(array): 326 | return sorted(array.items(), key=lambda x: x[1], reverse=True) 327 | 328 | 329 | def asort(array): 330 | return sorted(array.items(), key=lambda x: x[1]) 331 | 332 | 333 | def compact(*names): 334 | caller = inspect.stack()[1][0] 335 | vars = {} 336 | for n in names: 337 | if n in caller.f_locals: 338 | vars[n] = caller.f_locals[n] 339 | elif n in caller.f_globals: 340 | vars[n] = caller.f_globals[n] 341 | return vars 342 | 343 | 344 | def count(array): 345 | return len(array) 346 | 347 | 348 | def current(array): 349 | pass 350 | 351 | 352 | def each(array): 353 | pass 354 | 355 | 356 | def end(array): 357 | return array[-1] 358 | 359 | 360 | def extract(array): 361 | pass 362 | 363 | 364 | def in_array(needle, haystack): 365 | return needle in haystack 366 | 367 | 368 | def key_exists(key, array): 369 | return array_key_exists(key, array) 370 | 371 | 372 | def key(array): 373 | pass 374 | 375 | 376 | def krsort(array): 377 | return [(k, array[k]) for k in sorted(array.keys(), reverse=True)] 378 | 379 | 380 | def ksort(array): 381 | return [(k, array[k]) for k in sorted(array.keys())] 382 | 383 | 384 | def natcasesort(array): 385 | pass 386 | 387 | 388 | def natsort(array): 389 | pass 390 | 391 | 392 | def pos(array): 393 | pass 394 | 395 | 396 | def prev(array): 397 | pass 398 | 399 | 400 | def reset(array): 401 | pass 402 | 403 | 404 | def rsort(array): 405 | return array.sort(reverse=True) 406 | 407 | 408 | def shuffle(array): 409 | return random.shuffle(array) 410 | 411 | 412 | def sizeof(array): 413 | return len(array) 414 | 415 | 416 | def sort(array): 417 | return array.sort() 418 | 419 | 420 | def uasort(array): 421 | pass 422 | 423 | 424 | def uksort(array): 425 | pass 426 | 427 | 428 | def usort(array): 429 | pass 430 | 431 | 432 | """ 433 | Date/Time Functions 434 | """ 435 | 436 | 437 | def checkdate(month, day, year): 438 | import datetime 439 | try: 440 | month, day, year = map(int, (month, day, year)) 441 | datetime.date(year, month, day) 442 | return True 443 | except ValueError: 444 | return False 445 | pass 446 | 447 | 448 | def date_add(): 449 | pass 450 | 451 | 452 | def date_create_from_format(): 453 | pass 454 | 455 | 456 | def date_create_immutable_from_format(): 457 | pass 458 | 459 | 460 | def date_create_immutable(): 461 | pass 462 | 463 | 464 | def date_create(): 465 | pass 466 | 467 | 468 | def date_date_set(): 469 | pass 470 | 471 | 472 | def date_default_timezone_get(): 473 | return tzlocal.get_localzone().zone 474 | 475 | 476 | def date_default_timezone_set(timezone_identifier): 477 | pass 478 | 479 | 480 | def date_diff(): 481 | pass 482 | 483 | 484 | def date_format(): 485 | pass 486 | 487 | 488 | def date_get_last_errors(): 489 | pass 490 | 491 | 492 | def date_interval_create_from_date_string(): 493 | pass 494 | 495 | 496 | def date_interval_format(): 497 | pass 498 | 499 | 500 | def date_isodate_set(): 501 | pass 502 | 503 | 504 | def date_modify(): 505 | pass 506 | 507 | 508 | def date_offset_get(): 509 | pass 510 | 511 | 512 | def date_parse_from_format(): 513 | pass 514 | 515 | 516 | def date_parse(): 517 | pass 518 | 519 | 520 | def date_sub(): 521 | pass 522 | 523 | 524 | def date_sun_info(): 525 | pass 526 | 527 | 528 | def date_sunrise(): 529 | pass 530 | 531 | 532 | def date_sunset(): 533 | pass 534 | 535 | 536 | def date_time_set(): 537 | pass 538 | 539 | 540 | def date_timestamp_get(): 541 | pass 542 | 543 | 544 | def date_timestamp_set(): 545 | pass 546 | 547 | 548 | def date_timezone_get(): 549 | pass 550 | 551 | 552 | def date_timezone_set(): 553 | pass 554 | 555 | 556 | def date(format, timestamp=None): 557 | if timestamp is None: 558 | timestamp = py_time.time() 559 | return py_time.strftime(format, timestamp) 560 | 561 | 562 | def getdate(timestamp=None): 563 | if timestamp is None: 564 | timestamp = py_time.time() 565 | 566 | 567 | 568 | def gettimeofday(): 569 | pass 570 | 571 | 572 | def gmdate(): 573 | pass 574 | 575 | 576 | def gmmktime(): 577 | pass 578 | 579 | 580 | def gmstrftime(): 581 | pass 582 | 583 | 584 | def idate(): 585 | pass 586 | 587 | 588 | def localtime(timestamp): 589 | return py_time.localtime(timestamp) 590 | 591 | 592 | def microtime(get_as_float=False): 593 | d = datetime.now() 594 | t = py_time.mktime(d.timetuple()) 595 | if get_as_float: 596 | return t 597 | else: 598 | ms = d.microsecond / 1000000. 599 | return '%f %d' % (ms, t) 600 | 601 | 602 | def mktime(hour, minute, second, month, day, year): 603 | return py_time.mktime((year, month, day, hour, minute, second)) 604 | 605 | 606 | def strftime(): 607 | pass 608 | 609 | 610 | def strptime(): 611 | pass 612 | 613 | 614 | def strtotime(): 615 | pass 616 | 617 | 618 | def time(): 619 | return int(py_time.time()) 620 | 621 | 622 | def timezone_abbreviations_list(): 623 | pass 624 | 625 | 626 | def timezone_identifiers_list(): 627 | pass 628 | 629 | 630 | def timezone_location_get(): 631 | pass 632 | 633 | 634 | def timezone_name_from_abbr(): 635 | pass 636 | 637 | 638 | def timezone_name_get(): 639 | pass 640 | 641 | 642 | def timezone_offset_get(): 643 | pass 644 | 645 | 646 | def timezone_open(): 647 | pass 648 | 649 | 650 | def timezone_transitions_get(): 651 | pass 652 | 653 | 654 | def timezone_version_get(): 655 | pass 656 | 657 | 658 | ''' 659 | Filesystem Functions 660 | ''' 661 | 662 | 663 | def basename(path, suffix=None): 664 | base_name = os.path.basename(path) 665 | if suffix is not None and basename.endswith(suffix): 666 | return base_name[:-len(suffix)] 667 | return base_name 668 | 669 | 670 | def chgrp(filename, group): 671 | return os.chown(filename, None, group) 672 | 673 | 674 | def chmod(filename, mode): 675 | return os.chmod(filename, mode) 676 | 677 | 678 | def chown(filename, user): 679 | return os.chown(filename, user, None) 680 | 681 | 682 | def clearstatcache(): 683 | pass 684 | 685 | 686 | def copy(source, dest): 687 | return shutil.copy(source, dest) 688 | 689 | 690 | def delete(filename): 691 | return unlink(filename) 692 | 693 | 694 | def dirname(path): 695 | return os.path.dirname(path.rstrip(os.pathsep)) or '.' 696 | 697 | 698 | def disk_free_space(): 699 | pass 700 | 701 | 702 | def disk_total_space(): 703 | pass 704 | 705 | 706 | def diskfreespace(): 707 | pass 708 | 709 | 710 | def fclose(): 711 | pass 712 | 713 | 714 | def feof(): 715 | pass 716 | 717 | 718 | def fflush(handle): 719 | return handle.flush() 720 | 721 | 722 | def fgetc(): 723 | pass 724 | 725 | 726 | def fgetcsv(): 727 | pass 728 | 729 | 730 | def fgets(): 731 | pass 732 | 733 | 734 | def fgetss(): 735 | pass 736 | 737 | 738 | def file_exists(path): 739 | return os.path.exists(path) 740 | 741 | 742 | def file_get_contents(): 743 | pass 744 | 745 | 746 | def file_put_contents(filename, mode, data): 747 | file = open(filename, mode) 748 | file.write(data) 749 | file.close() 750 | 751 | 752 | def file(): 753 | pass 754 | 755 | 756 | def fileatime(filename): 757 | return os.path.getatime(filename) 758 | 759 | 760 | def filectime(filename): 761 | return os.path.getctime(filename) 762 | 763 | 764 | def filegroup(filename): 765 | return os.stat(filename).st_gid 766 | 767 | 768 | def fileinode(filename): 769 | return os.stat(filename).st_ino 770 | 771 | 772 | def filemtime(filename): 773 | return os.path.getmtime(filename) 774 | 775 | 776 | def fileowner(filename): 777 | return os.stat(filename).st_uid 778 | 779 | 780 | def fileperms(filename): 781 | return os.stat(filename).st_mode 782 | 783 | 784 | def filesize(filename): 785 | return os.path.getsize(filename) 786 | 787 | 788 | def filetype(): 789 | pass 790 | 791 | 792 | def flock(handle, operation): 793 | return fcntl.flock(handle, operation) 794 | 795 | 796 | def fnmatch(filename, pattern): 797 | return py_fnmatch.fnmatch(filename, pattern) 798 | 799 | 800 | def fopen(): 801 | pass 802 | 803 | 804 | def fpassthru(): 805 | pass 806 | 807 | 808 | def fputcsv(): 809 | pass 810 | 811 | 812 | def fputs(): 813 | pass 814 | 815 | 816 | def fread(handle, length): 817 | f = open(handle, "r+") 818 | return f.read(length) 819 | 820 | 821 | def fscanf(): 822 | pass 823 | 824 | 825 | def fseek(handle, offset, whence=0): 826 | # SEEK_SET=0 827 | # SEEK_CUR=1 828 | # SEEK_END=2 829 | return handle.seek(offset, whence) 830 | 831 | 832 | def fstat(handle): 833 | os.fstat(handle) 834 | 835 | 836 | def ftell(handle): 837 | return handle.tell() 838 | 839 | 840 | def ftruncate(handle, size): 841 | return handle.truncate(size) 842 | 843 | 844 | def fwrite(): 845 | pass 846 | 847 | 848 | def glob(pattern): 849 | return py_glob.glob(pattern) 850 | 851 | 852 | def is_dir(path): 853 | return os.path.isdir(path) 854 | 855 | 856 | def is_executable(filename): 857 | return os.access(filename, os.X_OK) 858 | 859 | 860 | def is_file(filename): 861 | return os.path.isfile(filename) 862 | 863 | 864 | def is_link(filename): 865 | return os.path.islink(filename) 866 | 867 | 868 | def is_readable(filename): 869 | return os.access(filename, os.R_OK) 870 | 871 | 872 | def is_uploaded_file(): 873 | pass 874 | 875 | 876 | def is_writable(filename): 877 | return os.access(filename, os.W_OK) 878 | 879 | 880 | def is_writeable(filename): 881 | return os.access(filename, os.W_OK) 882 | 883 | 884 | def lchgrp(filename, group): 885 | os.lchown(filename, None, group) 886 | 887 | 888 | def lchown(filename, user): 889 | return os.lchown(filename, user, None) 890 | 891 | 892 | def link(target, link): 893 | return os.link(target, link) 894 | 895 | 896 | def linkinfo(path): 897 | return os.stat(path).st_dev 898 | 899 | 900 | def lstat(filename): 901 | return os.lstat(filename) 902 | 903 | 904 | def mkdir(pathname, mode): 905 | return os.mkdir(pathname, mode) 906 | 907 | 908 | def move_uploaded_file(): 909 | pass 910 | 911 | 912 | def parse_ini_file(): 913 | pass 914 | 915 | 916 | def parse_ini_string(): 917 | pass 918 | 919 | 920 | def pathinfo(): 921 | pass 922 | 923 | 924 | def pclose(): 925 | pass 926 | 927 | 928 | def popen(): 929 | pass 930 | 931 | 932 | def readfile(filename): 933 | return open(filename, 'r').read() 934 | 935 | 936 | def readlink(path): 937 | return os.readlink(path) 938 | 939 | 940 | def realpath_cache_get(): 941 | pass 942 | 943 | 944 | def realpath_cache_size(): 945 | pass 946 | 947 | 948 | def realpath(path): 949 | return os.path.realpath(path) 950 | 951 | 952 | def rename(oldname, newname): 953 | return os.rename(oldname, newname) 954 | 955 | 956 | def rewind(): 957 | pass 958 | 959 | 960 | def rmdir(dirname): 961 | return os.rmdir(dirname) 962 | 963 | 964 | def set_file_buffer(): 965 | pass 966 | 967 | 968 | def stat(filename): 969 | return os.stat(filename) 970 | 971 | 972 | def symlink(target, link): 973 | return os.symlink(target, link) 974 | 975 | 976 | def tempnam(): 977 | pass 978 | 979 | 980 | def tmpfile(): 981 | pass 982 | 983 | 984 | def touch(filename, atime=None, mtime=None): 985 | return os.utime(filename, (atime, mtime)) 986 | 987 | 988 | def umask(mask): 989 | return os.umask(mask) 990 | 991 | 992 | def unlink(filename): 993 | return os.unlink(filename) 994 | 995 | 996 | """ 997 | Mathematical Functions 998 | """ 999 | 1000 | 1001 | def acos(arg): 1002 | return math.acos(arg) 1003 | 1004 | 1005 | def acosh(arg): 1006 | return math.acosh(arg) 1007 | 1008 | 1009 | def asin(arg): 1010 | return math.asin(arg) 1011 | 1012 | 1013 | def asinh(arg): 1014 | return math.asinh(arg) 1015 | 1016 | 1017 | def atan2(y, x): 1018 | return math.atan2(y, x) 1019 | 1020 | 1021 | def atan(arg): 1022 | return math.atan(arg) 1023 | 1024 | 1025 | def atanh(arg): 1026 | return math.atanh(arg) 1027 | 1028 | 1029 | def base_convert(number, from_base, to_base): 1030 | try: 1031 | base10 = int(number, from_base) 1032 | except ValueError: 1033 | raise 1034 | 1035 | if to_base < 2 or to_base > 36: 1036 | raise NotImplementedError 1037 | 1038 | digits = "0123456789abcdefghijklmnopqrstuvwxyz" 1039 | sign = '' 1040 | 1041 | if base10 == 0: 1042 | return '0' 1043 | elif base10 < 0: 1044 | sign = '-' 1045 | base10 = -base10 1046 | 1047 | s = '' 1048 | while base10 != 0: 1049 | r = base10 % to_base 1050 | r = int(r) 1051 | s = digits[r] + s 1052 | base10 //= to_base 1053 | 1054 | output_value = sign + s 1055 | return output_value 1056 | 1057 | 1058 | def bindec(binary_string): 1059 | return int(binary_string, 2) 1060 | 1061 | 1062 | def ceil(value): 1063 | return math.ceil(value) 1064 | 1065 | 1066 | def cos(arg): 1067 | return math.cos(arg) 1068 | 1069 | 1070 | def cosh(arg): 1071 | return math.cosh(arg) 1072 | 1073 | 1074 | def decbin(number): 1075 | return bin(number) 1076 | 1077 | 1078 | def dechex(number): 1079 | return hex(number) 1080 | 1081 | 1082 | def decoct(number): 1083 | return oct(number) 1084 | 1085 | 1086 | def deg2rad(number): 1087 | return math.radians(number) 1088 | 1089 | 1090 | def exp(arg): 1091 | return math.exp(arg) 1092 | 1093 | 1094 | def expm1(arg): 1095 | return math.exp(arg) - 1 1096 | 1097 | 1098 | def floor(value): 1099 | return math.floor(value) 1100 | 1101 | 1102 | def fmod(x, y): 1103 | return math.fmod(x, y) 1104 | 1105 | 1106 | def getrandmax(): 1107 | pass 1108 | 1109 | 1110 | def hexdec(hex_string): 1111 | return int(hex_string, 16) 1112 | 1113 | 1114 | def hypot(x, y): 1115 | return math.hypot(x, y) 1116 | 1117 | 1118 | def intdiv(dividend, divisor): 1119 | pass 1120 | 1121 | 1122 | def is_finite(val): 1123 | return math.isfinite(val) 1124 | 1125 | 1126 | def is_infinite(val): 1127 | return math.isinf(val) 1128 | 1129 | 1130 | def is_nan(val): 1131 | return math.isnan(val) 1132 | 1133 | 1134 | def lcg_value(): 1135 | pass 1136 | 1137 | 1138 | def log10(arg): 1139 | return math.log10(arg) 1140 | 1141 | 1142 | def log1p(arg): 1143 | return math.log1p(arg) 1144 | 1145 | 1146 | def log(arg, base): 1147 | return math.log(arg, base) 1148 | 1149 | 1150 | def mt_getrandmax(): 1151 | pass 1152 | 1153 | 1154 | def mt_rand(low, high): 1155 | return random.randint(low, high) 1156 | 1157 | 1158 | def mt_srand(): 1159 | pass 1160 | 1161 | 1162 | def octdec(octal_string): 1163 | return int(octal_string, 8) 1164 | 1165 | 1166 | def pi(): 1167 | return math.pi 1168 | 1169 | 1170 | def rad2deg(number): 1171 | return math.degrees(number) 1172 | 1173 | 1174 | def rand(minint, maxint): 1175 | return random.randint(minint, maxint) 1176 | 1177 | 1178 | def sin(arg): 1179 | return math.sin(arg) 1180 | 1181 | 1182 | def sinh(arg): 1183 | return math.sinh(arg) 1184 | 1185 | 1186 | def sqrt(arg): 1187 | return math.sqrt(arg) 1188 | 1189 | 1190 | def srand(seed=None): 1191 | if seed is None: 1192 | return random.seed() 1193 | return random.seed(seed) 1194 | 1195 | 1196 | def tan(arg): 1197 | return math.tan(arg) 1198 | 1199 | 1200 | def tanh(arg): 1201 | return math.tanh(arg) 1202 | 1203 | 1204 | ''' 1205 | Misc. Functions 1206 | ''' 1207 | 1208 | 1209 | def connection_aborted(): 1210 | pass 1211 | 1212 | 1213 | def connection_status(): 1214 | pass 1215 | 1216 | 1217 | def constant(): 1218 | pass 1219 | 1220 | 1221 | def define(): 1222 | pass 1223 | 1224 | 1225 | def defined(): 1226 | pass 1227 | 1228 | 1229 | def die(): 1230 | sys.exit() 1231 | 1232 | 1233 | def get_browser(): 1234 | pass 1235 | 1236 | 1237 | def __halt_compiler(): 1238 | pass 1239 | 1240 | 1241 | def highlight_file(): 1242 | pass 1243 | 1244 | 1245 | def highlight_string(): 1246 | pass 1247 | 1248 | 1249 | def hrtime(): 1250 | pass 1251 | 1252 | 1253 | def ignore_user_abort(): 1254 | pass 1255 | 1256 | 1257 | def pack(format_codes, args): 1258 | return struct.pack(format_codes, args) 1259 | 1260 | 1261 | def php_check_syntax(): 1262 | pass 1263 | 1264 | 1265 | def php_strip_whitespace(): 1266 | pass 1267 | 1268 | 1269 | def sapi_windows_cp_conv(): 1270 | pass 1271 | 1272 | 1273 | def sapi_windows_cp_get(): 1274 | pass 1275 | 1276 | 1277 | def sapi_windows_cp_is_utf8(): 1278 | pass 1279 | 1280 | 1281 | def sapi_windows_cp_set(): 1282 | pass 1283 | 1284 | 1285 | def sapi_windows_vt100_support(): 1286 | pass 1287 | 1288 | 1289 | def show_source(): 1290 | pass 1291 | 1292 | 1293 | def sleep(seconds): 1294 | py_time.sleep(seconds) 1295 | 1296 | 1297 | def sys_getloadavg(): 1298 | return os.getloadavg() 1299 | 1300 | 1301 | def time_nanosleep(seconds, nanoseconds): 1302 | pass 1303 | 1304 | 1305 | def time_sleep_until(timestamp): 1306 | py_time.sleep(timestamp - py_time.time()) 1307 | 1308 | 1309 | def uniqid(prefix=''): 1310 | return prefix + hex(int(py_time.time()))[2:10] + hex(int(py_time.time() * 1000000) % 0x100000)[2:7] 1311 | 1312 | 1313 | def unpack(format_codes, data): 1314 | return struct.unpack(format_codes, data) 1315 | 1316 | 1317 | def usleep(micro_seconds): 1318 | py_time.sleep(micro_seconds / 1000000.0) 1319 | 1320 | 1321 | ''' 1322 | Network Functions 1323 | ''' 1324 | 1325 | 1326 | def checkdnsrr(): 1327 | pass 1328 | 1329 | 1330 | def closelog(): 1331 | return py_syslog.closelog() 1332 | 1333 | 1334 | def define_syslog_variables(): 1335 | pass 1336 | 1337 | 1338 | def dns_check_record(): 1339 | pass 1340 | 1341 | 1342 | def dns_get_mx(hostname): 1343 | pass 1344 | 1345 | 1346 | def dns_get_record(): 1347 | pass 1348 | 1349 | 1350 | def fsockopen(hostname, port): 1351 | sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 1352 | sock.connect((hostname, port)) 1353 | return sock.makefile() 1354 | 1355 | 1356 | def gethostbyaddr(ip_address): 1357 | return socket.gethostbyaddr(ip_address) 1358 | 1359 | 1360 | def gethostbyname(hostname): 1361 | return socket.gethostbyname(hostname) 1362 | 1363 | 1364 | def gethostbynamel(hostname): 1365 | return socket.gethostbyname(hostname) 1366 | 1367 | 1368 | def gethostname(): 1369 | return socket.gethostname() 1370 | 1371 | 1372 | def getmxrr(): 1373 | pass 1374 | 1375 | 1376 | def getprotobyname(name): 1377 | return socket.getprotobyname(name) 1378 | 1379 | 1380 | def getprotobynumber(number): 1381 | table = {num: name[8:] for name, num in vars(socket).items() if name.startswith("IPPROTO")} 1382 | return table[number] 1383 | 1384 | 1385 | def getservbyname(service, protocol): 1386 | return socket.getservbyname(service, protocol) 1387 | 1388 | 1389 | def getservbyport(port, protocol): 1390 | return socket.getservbyport(port, protocol) 1391 | 1392 | 1393 | def header_register_callback(): 1394 | pass 1395 | 1396 | 1397 | def header_remove(): 1398 | pass 1399 | 1400 | 1401 | def header(): 1402 | pass 1403 | 1404 | 1405 | def headers_list(): 1406 | pass 1407 | 1408 | 1409 | def headers_sent(): 1410 | pass 1411 | 1412 | 1413 | def http_response_code(): 1414 | pass 1415 | 1416 | 1417 | def inet_ntop(in_addr): 1418 | return socket.inet_ntop(socket.AF_INET, in_addr) 1419 | 1420 | 1421 | def inet_pton(address): 1422 | return socket.inet_pton(socket.AF_INET, address) 1423 | 1424 | 1425 | def ip2long(ip_addr): 1426 | return unpack("!L", inet_aton(ip_addr))[0] 1427 | 1428 | 1429 | def long2ip(ip): 1430 | return inet_ntoa(pack("!L", ip)) 1431 | 1432 | 1433 | def openlog(ident, option, facility): 1434 | return py_syslog.openlog(ident, option, facility) 1435 | 1436 | 1437 | def pfsockopen(): 1438 | pass 1439 | 1440 | 1441 | def setcookie(name, value='', expire=0, path='', domain=''): 1442 | cookie = http.cookies.SimpleCookie() 1443 | cookie[name] = value 1444 | cookie[name]['domain'] = domain 1445 | cookie[name]['path'] = path 1446 | cookie[name]['expires'] = expire if expire != 0 else py_time.strftime("%a, %d-%b-%Y %H:%M:%S GMT") 1447 | return cookie.output() 1448 | 1449 | 1450 | def setrawcookie(): 1451 | pass 1452 | 1453 | 1454 | def socket_get_status(): 1455 | pass 1456 | 1457 | 1458 | def socket_set_blocking(): 1459 | pass 1460 | 1461 | 1462 | def socket_set_timeout(): 1463 | pass 1464 | 1465 | 1466 | def syslog(priority, message): 1467 | return py_syslog.syslog(priority, message) 1468 | 1469 | 1470 | ''' 1471 | Program execution Functions 1472 | ''' 1473 | 1474 | 1475 | def escapeshellarg(arg): 1476 | return "\\'".join("'" + p + "'" for p in arg.split("'")) 1477 | 1478 | 1479 | def escapeshellcmd(): 1480 | pass 1481 | 1482 | 1483 | def passthru(): 1484 | pass 1485 | 1486 | 1487 | def proc_lose(): 1488 | pass 1489 | 1490 | 1491 | def proc_et_tatus(): 1492 | pass 1493 | 1494 | 1495 | def proc_ice(): 1496 | pass 1497 | 1498 | 1499 | def proc_pen(): 1500 | pass 1501 | 1502 | 1503 | def proc_erminate(): 1504 | pass 1505 | 1506 | 1507 | def shell_xec(command): 1508 | return os.popen(command).read() 1509 | 1510 | 1511 | def system(command): 1512 | return os.system(command) 1513 | 1514 | 1515 | """ 1516 | Strings Functions 1517 | """ 1518 | 1519 | 1520 | def addcslashes(string): 1521 | pass 1522 | 1523 | 1524 | def addslashes(string): 1525 | pass 1526 | 1527 | 1528 | def bin2hex(string): 1529 | return binascii.hexlify(string) 1530 | 1531 | 1532 | def chop(string, character_mask=None): 1533 | return rtrim(string, character_mask) 1534 | 1535 | 1536 | def chunk_split(body, chunklen, end="\r\n"): 1537 | return end.join(textwrap.wrap(body, chunklen)) 1538 | 1539 | 1540 | def convert_cyr_string(string): 1541 | pass 1542 | 1543 | 1544 | def convert_uudecode(string): 1545 | pass 1546 | 1547 | 1548 | def convert_uuencode(string): 1549 | pass 1550 | 1551 | 1552 | def count_chars(s, mode=0): 1553 | temp = {chr(_x): 0 for _x in range(256)} 1554 | if mode == 0: 1555 | temp.update(Counter(s)) 1556 | return temp 1557 | elif mode == 1: 1558 | temp.update(Counter(s)) 1559 | res = temp.copy() 1560 | for i, j in temp.items(): 1561 | if not j: 1562 | res.pop(i) 1563 | return res 1564 | elif mode == 2: 1565 | temp.update(Counter(s)) 1566 | res = temp.copy() 1567 | for i, j in temp.items(): 1568 | if j: 1569 | res.pop(i) 1570 | return res 1571 | elif mode == 3: 1572 | res = "" 1573 | temp.update(Counter(s)) 1574 | for i, j in temp.items(): 1575 | if j: 1576 | res += i 1577 | return res 1578 | elif mode == 4: 1579 | res = "" 1580 | temp.update(Counter(s)) 1581 | for i, j in temp.items(): 1582 | if not j: 1583 | res += i 1584 | return res 1585 | else: 1586 | raise ValueError("Incorrect value of mode (%d)" % (mode,)) 1587 | 1588 | 1589 | def crc32(string): 1590 | return binascii.crc32(string) & 0xffffffff 1591 | 1592 | 1593 | def crypt(string, salt): 1594 | return py_crypt.crypt(string, salt) 1595 | 1596 | 1597 | def echo(string): 1598 | print(string) 1599 | 1600 | 1601 | def explode(delimiter, string, limit): 1602 | if limit == 0: 1603 | limit = 1 1604 | 1605 | if limit > 0: 1606 | return string.split(delimiter, limit) 1607 | else: 1608 | return string.split(delimiter)[:limit] 1609 | 1610 | 1611 | def fprintf(handle, format): 1612 | pass 1613 | 1614 | 1615 | def get_html_translation_table(string): 1616 | pass 1617 | 1618 | 1619 | def hebrev(string): 1620 | pass 1621 | 1622 | 1623 | def hebrevc(string): 1624 | pass 1625 | 1626 | 1627 | def hex2bin(hex_string): 1628 | return binascii.unhexlify(hex_string) 1629 | 1630 | 1631 | def html_entity_decode(string): 1632 | pass 1633 | 1634 | 1635 | def htmlentities(string): 1636 | pass 1637 | 1638 | 1639 | def htmlspecialchars_decode(string): 1640 | pass 1641 | 1642 | 1643 | def htmlspecialchars(string): 1644 | pass 1645 | 1646 | 1647 | def implode(glue='', pieces=[]): 1648 | return glue.join(pieces) 1649 | 1650 | 1651 | def join(glue='', pieces=[]): 1652 | return glue.join(pieces) 1653 | 1654 | 1655 | def lcfirst(string): 1656 | return string[0].lower() + string[1:] 1657 | 1658 | 1659 | def levenshtein(string1, string2): 1660 | n, m = len(string1), len(string2) 1661 | if n > m: 1662 | string1, string2 = string2, string1 1663 | n, m = m, n 1664 | 1665 | current = range(n + 1) 1666 | for i in range(1, m + 1): 1667 | previous, current = current, [i] + [0] * n 1668 | for j in range(1, n + 1): 1669 | add, delete = previous[j] + 1, current[j - 1] + 1 1670 | change = previous[j - 1] 1671 | if string1[j - 1] != string2[i - 1]: 1672 | change = change + 1 1673 | current[j] = min(add, delete, change) 1674 | 1675 | return current[n] 1676 | 1677 | 1678 | def localeconv(string): 1679 | pass 1680 | 1681 | 1682 | def ltrim(string, character_mask=None): 1683 | if character_mask is None: 1684 | return string.lstrip() 1685 | return string.lstrip(character_mask) 1686 | 1687 | 1688 | def md5_file(filename, raw_output=False): 1689 | crc = hashlib.md5() 1690 | fp = open(filename, 'rb') 1691 | for i in fp: 1692 | crc.update(i) 1693 | fp.close() 1694 | if raw_output: 1695 | return crc.digest() 1696 | return crc.hexdigest() 1697 | 1698 | 1699 | def md5(str, raw_output=False): 1700 | res = hashlib.md5(str.encode()) 1701 | if raw_output: 1702 | return res.digest() 1703 | return res.hexdigest() 1704 | 1705 | 1706 | def metaphone(string): 1707 | pass 1708 | 1709 | 1710 | def money_format(string): 1711 | pass 1712 | 1713 | 1714 | def nl_langinfo(string): 1715 | pass 1716 | 1717 | 1718 | def nl2br(string, is_xhtml=True): 1719 | if is_xhtml: 1720 | return string.replace('\n', '
\n') 1721 | else: 1722 | return string.replace('\n', '
\n') 1723 | 1724 | 1725 | def number_format(number, decimals): 1726 | locale.setlocale(locale.LC_NUMERIC, '') 1727 | return locale.format("%.*f", (decimals, number), True) 1728 | 1729 | 1730 | def parse_str(string): 1731 | return urllib.parse.parse_qs(string) 1732 | 1733 | 1734 | def printf(string): 1735 | return print(string) 1736 | 1737 | 1738 | def quoted_printable_decode(string): 1739 | return quopri.decodestring(string) 1740 | 1741 | 1742 | def quoted_printable_encode(string): 1743 | return quopri.encodestring(string) 1744 | 1745 | 1746 | def quotemeta(string): 1747 | pass 1748 | 1749 | 1750 | def rtrim(string, character_mask=None): 1751 | if character_mask is None: 1752 | return string.rstrip() 1753 | return string.rstrip(character_mask) 1754 | 1755 | 1756 | def setlocale(string): 1757 | pass 1758 | 1759 | 1760 | def sha1_file(filename, raw_output=False): 1761 | crc = hashlib.sha1() 1762 | fp = open(filename, 'rb') 1763 | for i in fp: 1764 | crc.update(i) 1765 | fp.close() 1766 | if raw_output: 1767 | return crc.digest() 1768 | return crc.hexdigest() 1769 | 1770 | 1771 | def sha1(string): 1772 | return hashlib.sha1(string.encode()).hexdigest() 1773 | 1774 | 1775 | def similar_text(string): 1776 | pass 1777 | 1778 | 1779 | def soundex(string): 1780 | pass 1781 | 1782 | 1783 | def sprintf(string): 1784 | pass 1785 | 1786 | 1787 | def sscanf(string): 1788 | pass 1789 | 1790 | 1791 | def str_getcsv(string, delimiter=',', enclosure='"', escape="\\"): 1792 | with io.StringIO(string) as f: 1793 | reader = csv.reader(f, delimiter=delimiter, quotechar=enclosure, escapechar=escape) 1794 | return next(reader) 1795 | 1796 | 1797 | def str_ireplace(search, replace, subject, count=0): 1798 | pattern = re.compile(search, re.IGNORECASE) 1799 | return pattern.sub(replace, subject, count) 1800 | 1801 | 1802 | def str_pad(string, pad_length, pad_string=' ', pad_type=1): 1803 | # STR_PAD_LEFT = 0 1804 | # STR_PAD_RIGHT = 1 1805 | # STR_PAD_BOTH = 2 1806 | if pad_type == 0: 1807 | return string.ljust(pad_length, pad_string) 1808 | elif pad_type == 2: 1809 | return string.center(pad_length, pad_string) 1810 | else: 1811 | return string.rjust(pad_length, pad_string) 1812 | 1813 | 1814 | def str_repeat(string, multiplier): 1815 | return string * multiplier 1816 | 1817 | 1818 | def str_replace(search, replace, subject, count=-1): 1819 | return subject.replace(search, replace, count) 1820 | 1821 | 1822 | def str_rot13(string): 1823 | enc = codecs.getencoder("rot-13") 1824 | return enc(string)[0] 1825 | 1826 | 1827 | def str_shuffle(string): 1828 | chars = list(string) 1829 | random.shuffle(chars) 1830 | return ''.join(chars) 1831 | 1832 | 1833 | def str_split(string, split_length=1): 1834 | return filter(None, re.split('(.{1,%d})' % split_length, string)) 1835 | 1836 | 1837 | def str_word_count(string, format=0, charlist=''): 1838 | if isinstance(string, str): 1839 | words = re.sub('[^\w ' + charlist + ']', '', string) 1840 | words = words.replace(' ', ' ').split(' ') 1841 | if format == 0: 1842 | return len(words) 1843 | elif format == 1: 1844 | return words 1845 | elif format == 2: 1846 | result = {} 1847 | for word in words: 1848 | result[string.find(word)] = word 1849 | return result 1850 | return False 1851 | 1852 | 1853 | def strcasecmp(string): 1854 | pass 1855 | 1856 | 1857 | def strchr(haystack, needle): 1858 | pos = haystack.find(needle) 1859 | if pos < 0: 1860 | return None 1861 | else: 1862 | return haystack[pos:] 1863 | 1864 | 1865 | def strcmp(string1, string2): 1866 | return (string1 > string2) - (string1 < string2) 1867 | 1868 | 1869 | def strcoll(string): 1870 | pass 1871 | 1872 | 1873 | def strcspn(string1, string2): 1874 | return len(list(takewhile(lambda x: x not in string2, string1))) 1875 | 1876 | 1877 | def strip_tags(string): 1878 | pass 1879 | 1880 | 1881 | def stripcslashes(string): 1882 | pass 1883 | 1884 | 1885 | def stripos(haystack, needle, offset=0): 1886 | return haystack.upper().find(needle.upper(), offset) 1887 | 1888 | 1889 | def stripslashes(string): 1890 | pass 1891 | 1892 | 1893 | def stristr(haystack, needle): 1894 | pos = haystack.upper().find(needle.upper()) 1895 | if pos < 0: 1896 | return None 1897 | else: 1898 | return haystack[pos:] 1899 | 1900 | 1901 | def strlen(string): 1902 | return len(string) 1903 | 1904 | 1905 | def strnatcasecmp(string): 1906 | pass 1907 | 1908 | 1909 | def strnatcmp(string): 1910 | pass 1911 | 1912 | 1913 | def strncasecmp(string): 1914 | pass 1915 | 1916 | 1917 | def strncmp(string): 1918 | pass 1919 | 1920 | 1921 | def strpbrk(haystack, char_list): 1922 | try: 1923 | pos = next(i for i, x in enumerate(haystack) if x in char_list) 1924 | return haystack[pos:] 1925 | except: 1926 | return None 1927 | 1928 | 1929 | def strpos(haystack, needle, offset=0): 1930 | pos = haystack.find(needle, offset) 1931 | if pos == -1: 1932 | return False 1933 | else: 1934 | return pos 1935 | 1936 | 1937 | def strrchr(haystack, needle): 1938 | return haystack.rfind(needle) 1939 | 1940 | 1941 | def strrev(string): 1942 | return string[::-1] 1943 | 1944 | 1945 | def strripos(haystack, needle, offset=0): 1946 | return haystack.upper().rfind(needle.upper(), offset) 1947 | 1948 | 1949 | def strrpos(haystack, needle, offset=0): 1950 | pos = haystack.rfind(needle, offset) 1951 | if pos == -1: 1952 | return False 1953 | else: 1954 | return pos 1955 | 1956 | 1957 | def strspn(subject, mask, start=0, length=None): 1958 | if not length: length = len(subject) 1959 | return len(re.search('^[' + mask + ']*', subject[start:start + length]).group(0)) 1960 | 1961 | 1962 | def strstr(haystack, needle): 1963 | pos = haystack.find(needle) 1964 | if pos < 0: 1965 | return None 1966 | else: 1967 | return haystack[pos:] 1968 | 1969 | 1970 | def strtok(string): 1971 | pass 1972 | 1973 | 1974 | def strtolower(string): 1975 | return string.lower() 1976 | 1977 | 1978 | def strtoupper(string): 1979 | return string.upper() 1980 | 1981 | 1982 | def strtr(string, from_str, to_str=None): 1983 | if is_array(from_str): 1984 | return string.translate(str.maketrans(from_str)) 1985 | return string.translate(str.maketrans(from_str, to_str)) 1986 | 1987 | 1988 | def substr_compare(string): 1989 | pass 1990 | 1991 | 1992 | def substr_count(haystack, needle, offset=0, length=0): 1993 | if offset == 0: 1994 | return haystack.count(needle) 1995 | else: 1996 | if length == 0: 1997 | return haystack.count(needle, offset) 1998 | else: 1999 | return haystack.count(needle, offset, offset + length) 2000 | 2001 | 2002 | def substr_replace(subject, replace, start, length=None): 2003 | if length is None: 2004 | return subject[:start] + replace 2005 | elif length < 0: 2006 | return subject[:start] + replace + subject[length:] 2007 | else: 2008 | return subject[:start] + replace + subject[start + length:] 2009 | 2010 | 2011 | def substr(string, start, length=None): 2012 | if len(string) >= start: 2013 | if start > 0: 2014 | return False 2015 | else: 2016 | return string[start:] 2017 | if not length: 2018 | return string[start:] 2019 | elif length > 0: 2020 | return string[start:start + length] 2021 | else: 2022 | return string[start:length] 2023 | 2024 | 2025 | def trim(string, character_mask=None): 2026 | if character_mask is None: 2027 | return string.strip() 2028 | return string.strip(character_mask) 2029 | 2030 | 2031 | def ucfirst(string): 2032 | return string[0].upper() + string[1:] 2033 | 2034 | 2035 | def ucwords(words): 2036 | return string.capwords(words) 2037 | 2038 | 2039 | def vfprintf(string): 2040 | pass 2041 | 2042 | 2043 | def vprintf(string): 2044 | pass 2045 | 2046 | 2047 | def vsprintf(string): 2048 | pass 2049 | 2050 | 2051 | def wordwrap(string, width): 2052 | return textwrap.wrap(string, width) 2053 | 2054 | 2055 | ''' 2056 | URL Functions 2057 | ''' 2058 | 2059 | 2060 | def base64_decode(data): 2061 | return base64.b64decode(data) 2062 | 2063 | 2064 | def base64_encode(data): 2065 | return base64.encode(data) 2066 | 2067 | 2068 | def get_headers(url): 2069 | return urllib.request.urlopen('%s' % url).headers 2070 | 2071 | 2072 | def get_meta_tags(url): 2073 | out = {} 2074 | html = urllib.request.urlopen('%s' % url).read() 2075 | m = re.findall("name=\"([^\"]*)\" content=\"([^\"]*)\"", html) 2076 | for i in m: 2077 | out[i[0]] = i[1] 2078 | return out 2079 | 2080 | 2081 | def http_build_query(query_data): 2082 | return urllib.parse.urlencode(query_data) 2083 | 2084 | 2085 | def parse_url(url): 2086 | return urllib.parse.urlparse(url) 2087 | 2088 | 2089 | def rawurldecode(string): 2090 | return urllib.parse.unquote(string) 2091 | 2092 | 2093 | def rawurlencode(string): 2094 | return urllib.parse.quote(string) 2095 | 2096 | 2097 | def urldecode(string): 2098 | return urllib.parse.unquote_plus(string) 2099 | 2100 | 2101 | def urlencode(string): 2102 | return urllib.parse.quote_plus(string) 2103 | 2104 | 2105 | ''' 2106 | Variable handling Functions 2107 | ''' 2108 | 2109 | 2110 | def boolval(variable): 2111 | return bool(variable) 2112 | 2113 | 2114 | def debug_zval_dump(): 2115 | pass 2116 | 2117 | 2118 | def doubleval(variable): 2119 | return float(variable) 2120 | 2121 | 2122 | def empty(variable): 2123 | if not variable: 2124 | return True 2125 | return False 2126 | 2127 | 2128 | def floatval(variable): 2129 | return float(variable) 2130 | 2131 | 2132 | def get_defined_vars(): 2133 | pass 2134 | 2135 | 2136 | def get_resource_type(): 2137 | pass 2138 | 2139 | 2140 | def gettype(variable): 2141 | return type(variable).__name__ 2142 | 2143 | 2144 | def import_request_variables(): 2145 | pass 2146 | 2147 | 2148 | def intval(variable, base=10): 2149 | return int(variable, base) 2150 | 2151 | 2152 | def is_array(variable): 2153 | return isinstance(variable, (list, tuple)) 2154 | 2155 | 2156 | def is_bool(variable): 2157 | return isinstance(variable, bool) 2158 | 2159 | 2160 | def is_callable(name): 2161 | return callable(name) 2162 | 2163 | 2164 | def is_countable(variable): 2165 | try: 2166 | Counter(variable) 2167 | return True 2168 | except: 2169 | return False 2170 | 2171 | 2172 | def is_double(variable): 2173 | return isinstance(variable, float) 2174 | 2175 | 2176 | def is_float(variable): 2177 | return isinstance(variable, float) 2178 | 2179 | 2180 | def is_int(variable): 2181 | return isinstance(variable, int) 2182 | 2183 | 2184 | def is_integer(variable): 2185 | return isinstance(variable, int) 2186 | 2187 | 2188 | def is_iterable(variable): 2189 | return is_array(variable) or isinstance(variable, collections.Iterable) 2190 | 2191 | 2192 | def is_long(variable): 2193 | return isinstance(variable, int) 2194 | 2195 | 2196 | def is_null(variable): 2197 | return variable is None 2198 | 2199 | 2200 | def is_numeric(variable): 2201 | return isinstance(variable, numbers.Number) or variable.isnumeric() 2202 | 2203 | 2204 | def is_object(variable): 2205 | return isinstance(variable, object) 2206 | 2207 | 2208 | def is_real(variable): 2209 | return isinstance(variable, float) 2210 | 2211 | 2212 | def is_resource(): 2213 | pass 2214 | 2215 | 2216 | def is_scalar(variable): 2217 | return isinstance(variable, (type(None), str, int, float, bool)) 2218 | 2219 | 2220 | def is_string(variable): 2221 | return isinstance(variable, str) 2222 | 2223 | 2224 | def isset(variable): 2225 | try: 2226 | variable 2227 | return True 2228 | except NameError: 2229 | return False 2230 | 2231 | 2232 | def print_r(variable): 2233 | pprint.pprint(variable) 2234 | 2235 | 2236 | def serialize(value): 2237 | return pickle.dump(value) 2238 | 2239 | 2240 | def settype(variable, variable_type): 2241 | pass 2242 | 2243 | 2244 | def strval(variable): 2245 | return str(variable) 2246 | 2247 | 2248 | def unserialize(): 2249 | pass 2250 | 2251 | 2252 | def unset(variable): 2253 | del variable 2254 | 2255 | 2256 | def var_dump(variable): 2257 | print(variable) 2258 | 2259 | 2260 | def var_export(variable): 2261 | print(variable) 2262 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PHP2Python 2 | 3 | Python alternatives for PHP internal (built-in) functions. Support Python 3 Only. 4 | 5 | * [php2go](https://github.com/syyongx/php2go) - Use Golang to implement PHP's common built-in functions 6 | 7 | ## Table of Contents 8 | * [Array Functions](#array-functions) 9 | * [Date/Time Functions](#datetime-functions) 10 | * [Filesystem Functions](#filesystem-functions) 11 | * [Mathematical Functions](#mathematical-functions) 12 | * [Misc. Functions](#misc-functions) 13 | * [Network Functions](#network-functions) 14 | * [Program execution Functions](#program-execution-functions) 15 | * [String Functions](#string-functions) 16 | * [URL Functions](#url-functions) 17 | * [Variable handling Functions](#variable-handling-functions) 18 | 19 | ## Array Functions 20 | 21 |
22 | ↥ back to top 23 |
24 | 25 | 26 | * [x] [array_change_key_case](http://php.net/manual/en/function.array-change-key-case.php) — Changes the case of all keys in an array 27 | * [x] [array_chunk](http://php.net/manual/en/function.array-chunk.php) — Split an array into chunks 28 | * [x] [array_column](http://php.net/manual/en/function.array-column.php) — Return the values from a single column in the input array 29 | * [x] [array_combine](http://php.net/manual/en/function.array-combine.php) — Creates an array by using one array for keys and another for its values 30 | * [x] [array_count_values](http://php.net/manual/en/function.array-count-values.php) — Counts all the values of an array 31 | * [ ] [array_diff_assoc](http://php.net/manual/en/function.array-diff-assoc.php) — Computes the difference of arrays with additional index check 32 | * [ ] [array_diff_key](http://php.net/manual/en/function.array-diff-key.php) — Computes the difference of arrays using keys for comparison 33 | * [ ] [array_diff_uassoc](http://php.net/manual/en/function.array-diff-uassoc.php) — Computes the difference of arrays with additional index check which is performed by a user supplied callback function 34 | * [ ] [array_diff_ukey](http://php.net/manual/en/function.array-diff-ukey.php) — Computes the difference of arrays using a callback function on the keys for comparison 35 | * [x] [array_diff](http://php.net/manual/en/function.array-diff.php) — Computes the difference of arrays 36 | * [x] [array_fill_keys](http://php.net/manual/en/function.array-fill-keys.php) — Fill an array with values, specifying keys 37 | * [x] [array_fill](http://php.net/manual/en/function.array-fill.php) — Fill an array with values 38 | * [x] [array_filter](http://php.net/manual/en/function.array-filter.php) — Filters elements of an array using a callback function 39 | * [x] [array_flip](http://php.net/manual/en/function.array-flip.php) — Exchanges all keys with their associated values in an array 40 | * [ ] [array_intersect_assoc](http://php.net/manual/en/function.array-intersect-assoc.php) — Computes the intersection of arrays with additional index check 41 | * [ ] [array_intersect_key](http://php.net/manual/en/function.array-intersect-key.php) — Computes the intersection of arrays using keys for comparison 42 | * [ ] [array_intersect_uassoc](http://php.net/manual/en/function.array-intersect-uassoc.php) — Computes the intersection of arrays with additional index check, compares indexes by a callback function 43 | * [ ] [array_intersect_ukey](http://php.net/manual/en/function.array-intersect-ukey.php) — Computes the intersection of arrays using a callback function on the keys for comparison 44 | * [ ] [array_intersect](http://php.net/manual/en/function.array-intersect.php) — Computes the intersection of arrays 45 | * [x] [array_key_exists](http://php.net/manual/en/function.array-key-exists.php) — Checks if the given key or index exists in the array 46 | * [x] [array_key_first](http://php.net/manual/en/function.array-key-first.php) — Gets the first key of an array 47 | * [x] [array_key_last](http://php.net/manual/en/function.array-key-last.php) — Gets the last key of an array 48 | * [x] [array_keys](http://php.net/manual/en/function.array-keys.php) — Return all the keys or a subset of the keys of an array 49 | * [x] [array_map](http://php.net/manual/en/function.array-map.php) — Applies the callback to the elements of the given arrays 50 | * [x] [array_merge_recursive](http://php.net/manual/en/function.array-merge-recursive.php) — Merge one or more arrays recursively 51 | * [x] [array_merge](http://php.net/manual/en/function.array-merge.php) — Merge one or more arrays 52 | * [ ] [array_multisort](http://php.net/manual/en/function.array-multisort.php) — Sort multiple or multi-dimensional arrays 53 | * [x] [array_pad](http://php.net/manual/en/function.array-pad.php) — Pad array to the specified length with a value 54 | * [x] [array_pop](http://php.net/manual/en/function.array-pop.php) — Pop the element off the end of array 55 | * [x] [array_product](http://php.net/manual/en/function.array-product.php) — Calculate the product of values in an array 56 | * [x] [array_push](http://php.net/manual/en/function.array-push.php) — Push one or more elements onto the end of array 57 | * [ ] [array_rand](http://php.net/manual/en/function.array-rand.php) — Pick one or more random keys out of an array 58 | * [x] [array_reduce](http://php.net/manual/en/function.array-reduce.php) — Iteratively reduce the array to a single value using a callback function 59 | * [x] [array_replace_recursive](http://php.net/manual/en/function.array-replace-recursive.php) — Replaces elements from passed arrays into the first array recursively 60 | * [ ] [array_replace](http://php.net/manual/en/function.array-replace.php) — Replaces elements from passed arrays into the first array 61 | * [x] [array_reverse](http://php.net/manual/en/function.array-reverse.php) — Return an array with elements in reverse order 62 | * [ ] [array_search](http://php.net/manual/en/function.array-search.php) — Searches the array for a given value and returns the first corresponding key if successful 63 | * [x] [array_shift](http://php.net/manual/en/function.array-shift.php) — Shift an element off the beginning of array 64 | * [x] [array_slice](http://php.net/manual/en/function.array-slice.php) — Extract a slice of the array 65 | * [x] [array_splice](http://php.net/manual/en/function.array-splice.php) — Remove a portion of the array and replace it with something else 66 | * [x] [array_sum](http://php.net/manual/en/function.array-sum.php) — Calculate the sum of values in an array 67 | * [ ] [array_udiff_assoc](http://php.net/manual/en/function.array-udiff-assoc.php) — Computes the difference of arrays with additional index check, compares data by a callback function 68 | * [ ] [array_udiff_uassoc](http://php.net/manual/en/function.array-udiff-uassoc.php) — Computes the difference of arrays with additional index check, compares data and indexes by a callback function 69 | * [ ] [array_udiff](http://php.net/manual/en/function.array-udiff.php) — Computes the difference of arrays by using a callback function for data comparison 70 | * [ ] [array_uintersect_assoc](http://php.net/manual/en/function.array-uintersect-assoc.php) — Computes the intersection of arrays with additional index check, compares data by a callback function 71 | * [ ] [array_uintersect_uassoc](http://php.net/manual/en/function.array-uintersect-uassoc.php) — Computes the intersection of arrays with additional index check, compares data and indexes by separate callback functions 72 | * [ ] [array_uintersect](http://php.net/manual/en/function.array-uintersect.php) — Computes the intersection of arrays, compares data by a callback function 73 | * [x] [array_unique](http://php.net/manual/en/function.array-unique.php) — Removes duplicate values from an array 74 | * [x] [array_unshift](http://php.net/manual/en/function.array-unshift.php) — Prepend one or more elements to the beginning of an array 75 | * [x] [array_values](http://php.net/manual/en/function.array-values.php) — Return all the values of an array 76 | * [ ] [array_walk_recursive](http://php.net/manual/en/function.array-walk-recursive.php) — Apply a user function recursively to every member of an array 77 | * [ ] [array_walk](http://php.net/manual/en/function.array-walk.php) — Apply a user supplied function to every member of an array 78 | * [ ] [array](http://php.net/manual/en/function.array.php) — Create an array 79 | * [ ] [arsort](http://php.net/manual/en/function.arsort.php) — Sort an array in reverse order and maintain index association 80 | * [ ] [asort](http://php.net/manual/en/function.asort.php) — Sort an array and maintain index association 81 | * [x] [compact](http://php.net/manual/en/function.compact.php) — Create array containing variables and their values 82 | * [x] [count](http://php.net/manual/en/function.count.php) — Count all elements in an array, or something in an object 83 | * [ ] [current](http://php.net/manual/en/function.current.php) — Return the current element in an array 84 | * [ ] [each](http://php.net/manual/en/function.each.php) — Return the current key and value pair from an array and advance the array cursor 85 | * [x] [end](http://php.net/manual/en/function.end.php) — Set the internal pointer of an array to its last element 86 | * [ ] [extract](http://php.net/manual/en/function.extract.php) — Import variables into the current symbol table from an array 87 | * [x] [in_array](http://php.net/manual/en/function.in-array.php) — Checks if a value exists in an array 88 | * [x] [key_exists](http://php.net/manual/en/function.key-exists.php) — Alias of array_key_exists 89 | * [ ] [key](http://php.net/manual/en/function.key.php) — Fetch a key from an array 90 | * [x] [krsort](http://php.net/manual/en/function.krsort.php) — Sort an array by key in reverse order 91 | * [x] [ksort](http://php.net/manual/en/function.ksort.php) — Sort an array by key 92 | * [ ] [list](http://php.net/manual/en/function.list.php) — Assign variables as if they were an array, `Built-in function in Python` 93 | * [ ] [natcasesort](http://php.net/manual/en/function.natcasesort.php) — Sort an array using a case insensitive "natural order" algorithm 94 | * [ ] [natsort](http://php.net/manual/en/function.natsort.php) — Sort an array using a "natural order" algorithm 95 | * [ ] [next](http://php.net/manual/en/function.next.php) — Advance the internal pointer of an array, `Built-in function in Python` 96 | * [ ] [pos](http://php.net/manual/en/function.pos.php) — Alias of current 97 | * [ ] [prev](http://php.net/manual/en/function.prev.php) — Rewind the internal array pointer 98 | * [ ] [range](http://php.net/manual/en/function.range.php) — Create an array containing a range of elements, `Built-in function in Python` 99 | * [ ] [reset](http://php.net/manual/en/function.reset.php) — Set the internal pointer of an array to its first element 100 | * [x] [rsort](http://php.net/manual/en/function.rsort.php) — Sort an array in reverse order 101 | * [x] [shuffle](http://php.net/manual/en/function.shuffle.php) — Shuffle an array 102 | * [x] [sizeof](http://php.net/manual/en/function.sizeof.php) — Alias of count 103 | * [x] [sort](http://php.net/manual/en/function.sort.php) — Sort an array 104 | * [ ] [uasort](http://php.net/manual/en/function.uasort.php) — Sort an array with a user-defined comparison function and maintain index association 105 | * [ ] [uksort](http://php.net/manual/en/function.uksort.php) — Sort an array by keys using a user-defined comparison function 106 | * [ ] [usort](http://php.net/manual/en/function.usort.php) — Sort an array by values using a user-defined comparison function 107 | 108 | ## Date/Time Functions 109 | 110 |
111 | ↥ back to top 112 |
113 | 114 | * [x] [checkdate](http://php.net/manual/en/function.checkdate.php) — Validate a Gregorian date 115 | * [ ] [date_add](http://php.net/manual/en/function.date-add.php) — Alias of DateTime::add 116 | * [ ] [date_create_from_format](http://php.net/manual/en/function.date-create-from-format.php) — Alias of DateTime::createFromFormat 117 | * [ ] [date_create_immutable_from_format](http://php.net/manual/en/function.date-create-immutable-from-format.php) — Alias of DateTimeImmutable::createFromFormat 118 | * [ ] [date_create_immutable](http://php.net/manual/en/function.date-create-immutable.php) — Alias of DateTimeImmutable::__construct 119 | * [ ] [date_create](http://php.net/manual/en/function.date-create.php) — Alias of DateTime::__construct 120 | * [ ] [date_date_set](http://php.net/manual/en/function.date-date-set.php) — Alias of DateTime::setDate 121 | * [x] [date_default_timezone_get](http://php.net/manual/en/function.date-default-timezone-get.php) — Gets the default timezone used by all date/time functions in a script 122 | * [ ] [date_default_timezone_set](http://php.net/manual/en/function.date-default-timezone-set.php) — Sets the default timezone used by all date/time functions in a script 123 | * [ ] [date_diff](http://php.net/manual/en/function.date-diff.php) — Alias of DateTime::diff 124 | * [ ] [date_format](http://php.net/manual/en/function.date-format.php) — Alias of DateTime::format 125 | * [ ] [date_get_last_errors](http://php.net/manual/en/function.date-get-last-errors.php) — Alias of DateTime::getLastErrors 126 | * [ ] [date_interval_create_from_date_string](http://php.net/manual/en/function.date-interval-create-from-date-string.php) — Alias of DateInterval::createFromDateString 127 | * [ ] [date_interval_format](http://php.net/manual/en/function.date-interval-format.php) — Alias of DateInterval::format 128 | * [ ] [date_isodate_set](http://php.net/manual/en/function.date-isodate-set.php) — Alias of DateTime::setISODate 129 | * [ ] [date_modify](http://php.net/manual/en/function.date-modify.php) — Alias of DateTime::modify 130 | * [ ] [date_offset_get](http://php.net/manual/en/function.date-offset-get.php) — Alias of DateTime::getOffset 131 | * [ ] [date_parse_from_format](http://php.net/manual/en/function.date-parse-from-format.php) — Get info about given date formatted according to the specified format 132 | * [ ] [date_parse](http://php.net/manual/en/function.date-parse.php) — Returns associative array with detailed info about given date 133 | * [ ] [date_sub](http://php.net/manual/en/function.date-sub.php) — Alias of DateTime::sub 134 | * [ ] [date_sun_info](http://php.net/manual/en/function.date-sun-info.php) — Returns an array with information about sunset/sunrise and twilight begin/end 135 | * [ ] [date_sunrise](http://php.net/manual/en/function.date-sunrise.php) — Returns time of sunrise for a given day and location 136 | * [ ] [date_sunset](http://php.net/manual/en/function.date-sunset.php) — Returns time of sunset for a given day and location 137 | * [ ] [date_time_set](http://php.net/manual/en/function.date-time-set.php) — Alias of DateTime::setTime 138 | * [ ] [date_timestamp_get](http://php.net/manual/en/function.date-timestamp-get.php) — Alias of DateTime::getTimestamp 139 | * [ ] [date_timestamp_set](http://php.net/manual/en/function.date-timestamp-set.php) — Alias of DateTime::setTimestamp 140 | * [ ] [date_timezone_get](http://php.net/manual/en/function.date-timezone-get.php) — Alias of DateTime::getTimezone 141 | * [ ] [date_timezone_set](http://php.net/manual/en/function.date-timezone-set.php) — Alias of DateTime::setTimezone 142 | * [x] [date](http://php.net/manual/en/function.date.php) — Format a local time/date 143 | * [ ] [getdate](http://php.net/manual/en/function.getdate.php) — Get date/time information 144 | * [ ] [gettimeofday](http://php.net/manual/en/function.gettimeofday.php) — Get current time 145 | * [ ] [gmdate](http://php.net/manual/en/function.gmdate.php) — Format a GMT/UTC date/time 146 | * [ ] [gmmktime](http://php.net/manual/en/function.gmmktime.php) — Get Unix timestamp for a GMT date 147 | * [ ] [gmstrftime](http://php.net/manual/en/function.gmstrftime.php) — Format a GMT/UTC time/date according to locale settings 148 | * [ ] [idate](http://php.net/manual/en/function.idate.php) — Format a local time/date as integer 149 | * [x] [localtime](http://php.net/manual/en/function.localtime.php) — Get the local time 150 | * [x] [microtime](http://php.net/manual/en/function.microtime.php) — Return current Unix timestamp with microseconds 151 | * [x] [mktime](http://php.net/manual/en/function.mktime.php) — Get Unix timestamp for a date 152 | * [ ] [strftime](http://php.net/manual/en/function.strftime.php) — Format a local time/date according to locale settings 153 | * [ ] [strptime](http://php.net/manual/en/function.strptime.php) — Parse a time/date generated with strftime 154 | * [ ] [strtotime](http://php.net/manual/en/function.strtotime.php) — Parse about any English textual datetime description into a Unix timestamp 155 | * [x] [time](http://php.net/manual/en/function.time.php) — Return current Unix timestamp 156 | * [ ] [timezone_abbreviations_list](http://php.net/manual/en/function.timezone-abbreviations-list.php) — Alias of DateTimeZone::listAbbreviations 157 | * [ ] [timezone_identifiers_list](http://php.net/manual/en/function.timezone-identifiers-list.php) — Alias of DateTimeZone::listIdentifiers 158 | * [ ] [timezone_location_get](http://php.net/manual/en/function.timezone-location-get.php) — Alias of DateTimeZone::getLocation 159 | * [ ] [timezone_name_from_abbr](http://php.net/manual/en/function.timezone-name-from-abbr.php) — Returns the timezone name from abbreviation 160 | * [ ] [timezone_name_get](http://php.net/manual/en/function.timezone-name-get.php) — Alias of DateTimeZone::getName 161 | * [ ] [timezone_offset_get](http://php.net/manual/en/function.timezone-offset-get.php) — Alias of DateTimeZone::getOffset 162 | * [ ] [timezone_open](http://php.net/manual/en/function.timezone-open.php) — Alias of DateTimeZone::__construct 163 | * [ ] [timezone_transitions_get](http://php.net/manual/en/function.timezone-transitions-get.php) — Alias of DateTimeZone::getTransitions 164 | * [ ] [timezone_version_get](http://php.net/manual/en/function.timezone-version-get.php) — Gets the version of the timezonedb 165 | 166 | ## Filesystem Functions 167 | 168 |
169 | ↥ back to top 170 |
171 | 172 | * [x] [basename](http://php.net/manual/en/function.basename.php) — Returns trailing name component of path 173 | * [x] [chgrp](http://php.net/manual/en/function.chgrp.php) — Changes file group 174 | * [x] [chmod](http://php.net/manual/en/function.chmod.php) — Changes file mode 175 | * [x] [chown](http://php.net/manual/en/function.chown.php) — Changes file owner 176 | * [ ] [clearstatcache](http://php.net/manual/en/function.clearstatcache.php) — Clears file status cache 177 | * [x] [copy](http://php.net/manual/en/function.copy.php) — Copies file 178 | * [x] [delete](http://php.net/manual/en/function.delete.php) — See unlink or unset 179 | * [x] [dirname](http://php.net/manual/en/function.dirname.php) — Returns a parent directory's path 180 | * [ ] [disk_free_space](http://php.net/manual/en/function.disk-free-space.php) — Returns available space on filesystem or disk partition 181 | * [ ] [disk_total_space](http://php.net/manual/en/function.disk-total-space.php) — Returns the total size of a filesystem or disk partition 182 | * [ ] [diskfreespace](http://php.net/manual/en/function.diskfreespace.php) — Alias of disk_free_space 183 | * [ ] [fclose](http://php.net/manual/en/function.fclose.php) — Closes an open file pointer 184 | * [ ] [feof](http://php.net/manual/en/function.feof.php) — Tests for end-of-file on a file pointer 185 | * [x] [fflush](http://php.net/manual/en/function.fflush.php) — Flushes the output to a file 186 | * [ ] [fgetc](http://php.net/manual/en/function.fgetc.php) — Gets character from file pointer 187 | * [ ] [fgetcsv](http://php.net/manual/en/function.fgetcsv.php) — Gets line from file pointer and parse for CSV fields 188 | * [ ] [fgets](http://php.net/manual/en/function.fgets.php) — Gets line from file pointer 189 | * [ ] [fgetss](http://php.net/manual/en/function.fgetss.php) — Gets line from file pointer and strip HTML tags 190 | * [x] [file_exists](http://php.net/manual/en/function.file-exists.php) — Checks whether a file or directory exists 191 | * [ ] [file_get_contents](http://php.net/manual/en/function.file-get-contents.php) — Reads entire file into a string 192 | * [x] [file_put_contents](http://php.net/manual/en/function.file-put-contents.php) — Write data to a file 193 | * [ ] [file](http://php.net/manual/en/function.file.php) — Reads entire file into an array 194 | * [x] [fileatime](http://php.net/manual/en/function.fileatime.php) — Gets last access time of file 195 | * [x] [filectime](http://php.net/manual/en/function.filectime.php) — Gets inode change time of file 196 | * [x] [filegroup](http://php.net/manual/en/function.filegroup.php) — Gets file group 197 | * [x] [fileinode](http://php.net/manual/en/function.fileinode.php) — Gets file inode 198 | * [x] [filemtime](http://php.net/manual/en/function.filemtime.php) — Gets file modification time 199 | * [x] [fileowner](http://php.net/manual/en/function.fileowner.php) — Gets file owner 200 | * [x] [fileperms](http://php.net/manual/en/function.fileperms.php) — Gets file permissions 201 | * [x] [filesize](http://php.net/manual/en/function.filesize.php) — Gets file size 202 | * [ ] [filetype](http://php.net/manual/en/function.filetype.php) — Gets file type 203 | * [x] [flock](http://php.net/manual/en/function.flock.php) — Portable advisory file locking 204 | * [x] [fnmatch](http://php.net/manual/en/function.fnmatch.php) — Match filename against a pattern 205 | * [ ] [fopen](http://php.net/manual/en/function.fopen.php) — Opens file or URL 206 | * [ ] [fpassthru](http://php.net/manual/en/function.fpassthru.php) — Output all remaining data on a file pointer 207 | * [ ] [fputcsv](http://php.net/manual/en/function.fputcsv.php) — Format line as CSV and write to file pointer 208 | * [ ] [fputs](http://php.net/manual/en/function.fputs.php) — Alias of fwrite 209 | * [x] [fread](http://php.net/manual/en/function.fread.php) — Binary-safe file read 210 | * [ ] [fscanf](http://php.net/manual/en/function.fscanf.php) — Parses input from a file according to a format 211 | * [x] [fseek](http://php.net/manual/en/function.fseek.php) — Seeks on a file pointer 212 | * [x] [fstat](http://php.net/manual/en/function.fstat.php) — Gets information about a file using an open file pointer 213 | * [x] [ftell](http://php.net/manual/en/function.ftell.php) — Returns the current position of the file read/write pointer 214 | * [x] [ftruncate](http://php.net/manual/en/function.ftruncate.php) — Truncates a file to a given length 215 | * [ ] [fwrite](http://php.net/manual/en/function.fwrite.php) — Binary-safe file write 216 | * [x] [glob](http://php.net/manual/en/function.glob.php) — Find pathnames matching a pattern 217 | * [x] [is_dir](http://php.net/manual/en/function.is-dir.php) — Tells whether the filename is a directory 218 | * [x] [is_executable](http://php.net/manual/en/function.is-executable.php) — Tells whether the filename is executable 219 | * [x] [is_file](http://php.net/manual/en/function.is-file.php) — Tells whether the filename is a regular file 220 | * [x] [is_link](http://php.net/manual/en/function.is-link.php) — Tells whether the filename is a symbolic link 221 | * [x] [is_readable](http://php.net/manual/en/function.is-readable.php) — Tells whether a file exists and is readable 222 | * [ ] [is_uploaded_file](http://php.net/manual/en/function.is-uploaded-file.php) — Tells whether the file was uploaded via HTTP POST 223 | * [x] [is_writable](http://php.net/manual/en/function.is-writable.php) — Tells whether the filename is writable 224 | * [x] [is_writeable](http://php.net/manual/en/function.is-writeable.php) — Alias of is_writable 225 | * [x] [lchgrp](http://php.net/manual/en/function.lchgrp.php) — Changes group ownership of symlink 226 | * [x] [lchown](http://php.net/manual/en/function.lchown.php) — Changes user ownership of symlink 227 | * [x] [link](http://php.net/manual/en/function.link.php) — Create a hard link 228 | * [x] [linkinfo](http://php.net/manual/en/function.linkinfo.php) — Gets information about a link 229 | * [x] [lstat](http://php.net/manual/en/function.lstat.php) — Gives information about a file or symbolic link 230 | * [x] [mkdir](http://php.net/manual/en/function.mkdir.php) — Makes directory 231 | * [ ] [move_uploaded_file](http://php.net/manual/en/function.move-uploaded-file.php) — Moves an uploaded file to a new location 232 | * [ ] [parse_ini_file](http://php.net/manual/en/function.parse-ini-file.php) — Parse a configuration file 233 | * [ ] [parse_ini_string](http://php.net/manual/en/function.parse-ini-string.php) — Parse a configuration string 234 | * [ ] [pathinfo](http://php.net/manual/en/function.pathinfo.php) — Returns information about a file path 235 | * [ ] [pclose](http://php.net/manual/en/function.pclose.php) — Closes process file pointer 236 | * [ ] [popen](http://php.net/manual/en/function.popen.php) — Opens process file pointer 237 | * [x] [readfile](http://php.net/manual/en/function.readfile.php) — Outputs a file 238 | * [x] [readlink](http://php.net/manual/en/function.readlink.php) — Returns the target of a symbolic link 239 | * [ ] [realpath_cache_get](http://php.net/manual/en/function.realpath-cache-get.php) — Get realpath cache entries 240 | * [ ] [realpath_cache_size](http://php.net/manual/en/function.realpath-cache-size.php) — Get realpath cache size 241 | * [x] [realpath](http://php.net/manual/en/function.realpath.php) — Returns canonicalized absolute pathname 242 | * [x] [rename](http://php.net/manual/en/function.rename.php) — Renames a file or directory 243 | * [ ] [rewind](http://php.net/manual/en/function.rewind.php) — Rewind the position of a file pointer 244 | * [x] [rmdir](http://php.net/manual/en/function.rmdir.php) — Removes directory 245 | * [ ] [set_file_buffer](http://php.net/manual/en/function.set-file-buffer.php) — Alias of stream_set_write_buffer 246 | * [x] [stat](http://php.net/manual/en/function.stat.php) — Gives information about a file 247 | * [x] [symlink](http://php.net/manual/en/function.symlink.php) — Creates a symbolic link 248 | * [ ] [tempnam](http://php.net/manual/en/function.tempnam.php) — Create file with unique file name 249 | * [ ] [tmpfile](http://php.net/manual/en/function.tmpfile.php) — Creates a temporary file 250 | * [x] [touch](http://php.net/manual/en/function.touch.php) — Sets access and modification time of file 251 | * [x] [umask](http://php.net/manual/en/function.umask.php) — Changes the current umask 252 | * [x] [unlink](http://php.net/manual/en/function.unlink.php) — Deletes a file 253 | 254 | ## Mathematical Functions 255 | 256 |
257 | ↥ back to top 258 |
259 | 260 | * [ ] [abs](http://php.net/manual/en/function.abs.php) — Absolute value, `Built-in function in Python` 261 | * [x] [acos](http://php.net/manual/en/function.acos.php) — Arc cosine 262 | * [x] [acosh](http://php.net/manual/en/function.acosh.php) — Inverse hyperbolic cosine 263 | * [x] [asin](http://php.net/manual/en/function.asin.php) — Arc sine 264 | * [x] [asinh](http://php.net/manual/en/function.asinh.php) — Inverse hyperbolic sine 265 | * [x] [atan2](http://php.net/manual/en/function.atan2.php) — Arc tangent of two variables 266 | * [x] [atan](http://php.net/manual/en/function.atan.php) — Arc tangent 267 | * [x] [atanh](http://php.net/manual/en/function.atanh.php) — Inverse hyperbolic tangent 268 | * [x] [base_convert](http://php.net/manual/en/function.base-convert.php) — Convert a number between arbitrary bases 269 | * [x] [bindec](http://php.net/manual/en/function.bindec.php) — Binary to decimal 270 | * [x] [ceil](http://php.net/manual/en/function.ceil.php) — Round fractions up 271 | * [x] [cos](http://php.net/manual/en/function.cos.php) — Cosine 272 | * [x] [cosh](http://php.net/manual/en/function.cosh.php) — Hyperbolic cosine 273 | * [x] [decbin](http://php.net/manual/en/function.decbin.php) — Decimal to binary 274 | * [x] [dechex](http://php.net/manual/en/function.dechex.php) — Decimal to hexadecimal 275 | * [x] [decoct](http://php.net/manual/en/function.decoct.php) — Decimal to octal 276 | * [x] [deg2rad](http://php.net/manual/en/function.deg2rad.php) — Converts the number in degrees to the radian equivalent 277 | * [x] [exp](http://php.net/manual/en/function.exp.php) — Calculates the exponent of e 278 | * [x] [expm1](http://php.net/manual/en/function.expm1.php) — Returns exp(number) - 1, computed in a way that is accurate even when the value of number is close to zero 279 | * [x] [floor](http://php.net/manual/en/function.floor.php) — Round fractions down 280 | * [x] [fmod](http://php.net/manual/en/function.fmod.php) — Returns the floating point remainder (modulo) of the division of the arguments 281 | * [ ] [getrandmax](http://php.net/manual/en/function.getrandmax.php) — Show largest possible random value 282 | * [x] [hexdec](http://php.net/manual/en/function.hexdec.php) — Hexadecimal to decimal 283 | * [x] [hypot](http://php.net/manual/en/function.hypot.php) — Calculate the length of the hypotenuse of a right-angle triangle 284 | * [ ] [intdiv](http://php.net/manual/en/function.intdiv.php) — Integer division 285 | * [x] [is_finite](http://php.net/manual/en/function.is-finite.php) — Finds whether a value is a legal finite number 286 | * [x] [is_infinite](http://php.net/manual/en/function.is-infinite.php) — Finds whether a value is infinite 287 | * [x] [is_nan](http://php.net/manual/en/function.is-nan.php) — Finds whether a value is not a number 288 | * [ ] [lcg_value](http://php.net/manual/en/function.lcg-value.php) — Combined linear congruential generator 289 | * [x] [log10](http://php.net/manual/en/function.log10.php) — Base-10 logarithm 290 | * [x] [log1p](http://php.net/manual/en/function.log1p.php) — Returns log(1 + number), computed in a way that is accurate even when the value of number is close to zero 291 | * [x] [log](http://php.net/manual/en/function.log.php) — Natural logarithm 292 | * [ ] [max](http://php.net/manual/en/function.max.php) — Find highest value, `Built-in function in Python` 293 | * [ ] [min](http://php.net/manual/en/function.min.php) — Find lowest value, `Built-in function in Python` 294 | * [ ] [mt_getrandmax](http://php.net/manual/en/function.mt-getrandmax.php) — Show largest possible random value 295 | * [x] [mt_rand](http://php.net/manual/en/function.mt-rand.php) — Generate a random value via the Mersenne Twister Random Number Generator 296 | * [ ] [mt_srand](http://php.net/manual/en/function.mt-srand.php) — Seeds the Mersenne Twister Random Number Generator 297 | * [x] [octdec](http://php.net/manual/en/function.octdec.php) — Octal to decimal 298 | * [x] [pi](http://php.net/manual/en/function.pi.php) — Get value of pi 299 | * [ ] [pow](http://php.net/manual/en/function.pow.php) — Exponential expression, `Built-in function in Python` 300 | * [x] [rad2deg](http://php.net/manual/en/function.rad2deg.php) — Converts the radian number to the equivalent number in degrees 301 | * [x] [rand](http://php.net/manual/en/function.rand.php) — Generate a random integer 302 | * [ ] [round](http://php.net/manual/en/function.round.php) — Rounds a float, `Built-in function in Python` 303 | * [x] [sin](http://php.net/manual/en/function.sin.php) — Sine 304 | * [x] [sinh](http://php.net/manual/en/function.sinh.php) — Hyperbolic sine 305 | * [x] [sqrt](http://php.net/manual/en/function.sqrt.php) — Square root 306 | * [x] [srand](http://php.net/manual/en/function.srand.php) — Seed the random number generator 307 | * [x] [tan](http://php.net/manual/en/function.tan.php) — Tangent 308 | * [x] [tanh](http://php.net/manual/en/function.tanh.php) — Hyperbolic tangent 309 | 310 | ## Misc. Functions 311 | 312 |
313 | ↥ back to top 314 |
315 | 316 | * [ ] [connection_aborted](http://php.net/manual/en/function.connection-aborted.php) — Check whether client disconnected 317 | * [ ] [connection_status](http://php.net/manual/en/function.connection-status.php) — Returns connection status bitfield 318 | * [ ] [constant](http://php.net/manual/en/function.constant.php) — Returns the value of a constant 319 | * [ ] [define](http://php.net/manual/en/function.define.php) — Defines a named constant 320 | * [ ] [defined](http://php.net/manual/en/function.defined.php) — Checks whether a given named constant exists 321 | * [x] [die](http://php.net/manual/en/function.die.php) — Equivalent to exit 322 | * [ ] [eval](http://php.net/manual/en/function.eval.php) — Evaluate a string as PHP code 323 | * [ ] [exit](http://php.net/manual/en/function.exit.php) — Output a message and terminate the current script 324 | * [ ] [get_browser](http://php.net/manual/en/function.get-browser.php) — Tells what the user's browser is capable of 325 | * [ ] [__halt_compiler](http://php.net/manual/en/function.halt-compiler.php) — Halts the compiler execution 326 | * [ ] [highlight_file](http://php.net/manual/en/function.highlight-file.php) — Syntax highlighting of a file 327 | * [ ] [highlight_string](http://php.net/manual/en/function.highlight-string.php) — Syntax highlighting of a string 328 | * [ ] [hrtime](http://php.net/manual/en/function.hrtime.php) — Get the system's high resolution time 329 | * [ ] [ignore_user_abort](http://php.net/manual/en/function.ignore-user-abort.php) — Set whether a client disconnect should abort script execution 330 | * [x] [pack](http://php.net/manual/en/function.pack.php) — Pack data into binary string 331 | * [ ] [php_check_syntax](http://php.net/manual/en/function.php-check-syntax.php) — Check the PHP syntax of (and execute) the specified file 332 | * [ ] [php_strip_whitespace](http://php.net/manual/en/function.php-strip-whitespace.php) — Return source with stripped comments and whitespace 333 | * [ ] [sapi_windows_cp_conv](http://php.net/manual/en/function.sapi-windows-cp-conv.php) — Convert string from one codepage to another 334 | * [ ] [sapi_windows_cp_get](http://php.net/manual/en/function.sapi-windows-cp-get.php) — Get process codepage 335 | * [ ] [sapi_windows_cp_is_utf8](http://php.net/manual/en/function.sapi-windows-cp-is-utf8.php) — Indicates whether the codepage is UTF-8 compatible 336 | * [ ] [sapi_windows_cp_set](http://php.net/manual/en/function.sapi-windows-cp-set.php) — Set process codepage 337 | * [ ] [sapi_windows_vt100_support](http://php.net/manual/en/function.sapi-windows-vt100-support.php) — Get or set VT100 support for the specified stream associated to an output buffer of a Windows console. 338 | * [ ] [show_source](http://php.net/manual/en/function.show-source.php) — Alias of highlight_file 339 | * [x] [sleep](http://php.net/manual/en/function.sleep.php) — Delay execution 340 | * [x] [sys_getloadavg](http://php.net/manual/en/function.sys-getloadavg.php) — Gets system load average 341 | * [ ] [time_nanosleep](http://php.net/manual/en/function.time-nanosleep.php) — Delay for a number of seconds and nanoseconds 342 | * [x] [time_sleep_until](http://php.net/manual/en/function.time-sleep-until.php) — Make the script sleep until the specified time 343 | * [x] [uniqid](http://php.net/manual/en/function.uniqid.php) — Generate a unique ID 344 | * [x] [unpack](http://php.net/manual/en/function.unpack.php) — Unpack data from binary string 345 | * [x] [usleep](http://php.net/manual/en/function.usleep.php) — Delay execution in microseconds 346 | 347 | ## Network Functions 348 | 349 |
350 | ↥ back to top 351 |
352 | 353 | * [ ] [checkdnsrr](http://php.net/manual/en/function.checkdnsrr.php) — Check DNS records corresponding to a given Internet host name or IP address 354 | * [x] [closelog](http://php.net/manual/en/function.closelog.php) — Close connection to system logger 355 | * [ ] [define_syslog_variables](http://php.net/manual/en/function.define-syslog-variables.php) — Initializes all syslog related variables 356 | * [ ] [dns_check_record](http://php.net/manual/en/function.dns-check-record.php) — Alias of checkdnsrr 357 | * [ ] [dns_get_mx](http://php.net/manual/en/function.dns-get-mx.php) — Alias of getmxrr 358 | * [ ] [dns_get_record](http://php.net/manual/en/function.dns-get-record.php) — Fetch DNS Resource Records associated with a hostname 359 | * [x] [fsockopen](http://php.net/manual/en/function.fsockopen.php) — Open Internet or Unix domain socket connection 360 | * [x] [gethostbyaddr](http://php.net/manual/en/function.gethostbyaddr.php) — Get the Internet host name corresponding to a given IP address 361 | * [x] [gethostbyname](http://php.net/manual/en/function.gethostbyname.php) — Get the IPv4 address corresponding to a given Internet host name 362 | * [x] [gethostbynamel](http://php.net/manual/en/function.gethostbynamel.php) — Get a list of IPv4 addresses corresponding to a given Internet host name 363 | * [x] [gethostname](http://php.net/manual/en/function.gethostname.php) — Gets the host name 364 | * [ ] [getmxrr](http://php.net/manual/en/function.getmxrr.php) — Get MX records corresponding to a given Internet host name 365 | * [x] [getprotobyname](http://php.net/manual/en/function.getprotobyname.php) — Get protocol number associated with protocol name 366 | * [x] [getprotobynumber](http://php.net/manual/en/function.getprotobynumber.php) — Get protocol name associated with protocol number 367 | * [x] [getservbyname](http://php.net/manual/en/function.getservbyname.php) — Get port number associated with an Internet service and protocol 368 | * [x] [getservbyport](http://php.net/manual/en/function.getservbyport.php) — Get Internet service which corresponds to port and protocol 369 | * [ ] [header_register_callback](http://php.net/manual/en/function.header-register-callback.php) — Call a header function 370 | * [ ] [header_remove](http://php.net/manual/en/function.header-remove.php) — Remove previously set headers 371 | * [ ] [header](http://php.net/manual/en/function.header.php) — Send a raw HTTP header 372 | * [ ] [headers_list](http://php.net/manual/en/function.headers-list.php) — Returns a list of response headers sent (or ready to send) 373 | * [ ] [headers_sent](http://php.net/manual/en/function.headers-sent.php) — Checks if or where headers have been sent 374 | * [ ] [http_response_code](http://php.net/manual/en/function.http-response-code.php) — Get or Set the HTTP response code 375 | * [x] [inet_ntop](http://php.net/manual/en/function.inet-ntop.php) — Converts a packed internet address to a human readable representation 376 | * [x] [inet_pton](http://php.net/manual/en/function.inet-pton.php) — Converts a human readable IP address to its packed in_addr representation 377 | * [x] [ip2long](http://php.net/manual/en/function.ip2long.php) — Converts a string containing an (IPv4) Internet Protocol dotted address into a long integer 378 | * [x] [long2ip](http://php.net/manual/en/function.long2ip.php) — Converts an long integer address into a string in (IPv4) Internet standard dotted format 379 | * [x] [openlog](http://php.net/manual/en/function.openlog.php) — Open connection to system logger 380 | * [ ] [pfsockopen](http://php.net/manual/en/function.pfsockopen.php) — Open persistent Internet or Unix domain socket connection 381 | * [x] [setcookie](http://php.net/manual/en/function.setcookie.php) — Send a cookie 382 | * [ ] [setrawcookie](http://php.net/manual/en/function.setrawcookie.php) — Send a cookie without urlencoding the cookie value 383 | * [ ] [socket_get_status](http://php.net/manual/en/function.socket-get-status.php) — Alias of stream_get_meta_data 384 | * [ ] [socket_set_blocking](http://php.net/manual/en/function.socket-set-blocking.php) — Alias of stream_set_blocking 385 | * [ ] [socket_set_timeout](http://php.net/manual/en/function.socket-set-timeout.php) — Alias of stream_set_timeout 386 | * [x] [syslog](http://php.net/manual/en/function.syslog.php) — Generate a system log message 387 | 388 | ## Program execution Functions 389 | 390 |
391 | ↥ back to top 392 |
393 | 394 | * [x] [escapeshellarg](http://php.net/manual/en/function.escapeshellarg.php) — Escape a string to be used as a shell argument 395 | * [ ] [escapeshellcmd](http://php.net/manual/en/function.escapeshellcmd.php) — Escape shell metacharacters 396 | * [ ] [exec](http://php.net/manual/en/function.exec.php) — Execute an external program 397 | * [ ] [passthru](http://php.net/manual/en/function.passthru.php) — Execute an external program and display raw output 398 | * [ ] [proc_close](http://php.net/manual/en/function.proc-close.php) — Close a process opened by proc_open and return the exit code of that process 399 | * [ ] [proc_get_status](http://php.net/manual/en/function.proc-get-status.php) — Get information about a process opened by proc_open 400 | * [ ] [proc_nice](http://php.net/manual/en/function.proc-nice.php) — Change the priority of the current process 401 | * [ ] [proc_open](http://php.net/manual/en/function.proc-open.php) — Execute a command and open file pointers for input/output 402 | * [ ] [proc_terminate](http://php.net/manual/en/function.proc-terminate.php) — Kills a process opened by proc_open 403 | * [x] [shell_exec](http://php.net/manual/en/function.shell-exec.php) — Execute command via shell and return the complete output as a string 404 | * [x] [system](http://php.net/manual/en/function.system.php) — Execute an external program and display the output 405 | 406 | ## String Functions 407 | 408 |
409 | ↥ back to top 410 |
411 | 412 | * [ ] [addcslashes](http://php.net/manual/en/function.addcslashes.php) — Quote string with slashes in a C style 413 | * [ ] [addslashes](http://php.net/manual/en/function.addslashes.php) — Quote string with slashes 414 | * [x] [bin2hex](http://php.net/manual/en/function.bin2hex.php) — Convert binary data into hexadecimal representation 415 | * [x] [chop](http://php.net/manual/en/function.chop.php) — Alias of rtrim 416 | * [x] [chr](http://php.net/manual/en/function.chr.php) — Generate a single-byte string from a number, `Built-in function in Python` 417 | * [x] [chunk_split](http://php.net/manual/en/function.chunk-split.php) — Split a string into smaller chunks 418 | * [ ] [convert_cyr_string](http://php.net/manual/en/function.convert-cyr-string.php) — Convert from one Cyrillic character set to another 419 | * [ ] [convert_uudecode](http://php.net/manual/en/function.convert-uudecode.php) — Decode a uuencoded string 420 | * [ ] [convert_uuencode](http://php.net/manual/en/function.convert-uuencode.php) — Uuencode a string 421 | * [x] [count_chars](http://php.net/manual/en/function.count-chars.php) — Return information about characters used in a string 422 | * [x] [crc32](http://php.net/manual/en/function.crc32.php) — Calculates the crc32 polynomial of a string 423 | * [x] [crypt](http://php.net/manual/en/function.crypt.php) — One-way string hashing 424 | * [x] [echo](http://php.net/manual/en/function.echo.php) — Output one or more strings 425 | * [x] [explode](http://php.net/manual/en/function.explode.php) — Split a string by a string 426 | * [ ] [fprintf](http://php.net/manual/en/function.fprintf.php) — Write a formatted string to a stream 427 | * [ ] [get_html_translation_table](http://php.net/manual/en/function.get-html-translation-table.php) — Returns the translation table used by htmlspecialchars and htmlentities 428 | * [ ] [hebrev](http://php.net/manual/en/function.hebrev.php) — Convert logical Hebrew text to visual text 429 | * [ ] [hebrevc](http://php.net/manual/en/function.hebrevc.php) — Convert logical Hebrew text to visual text with newline conversion 430 | * [x] [hex2bin](http://php.net/manual/en/function.hex2bin.php) — Decodes a hexadecimally encoded binary string 431 | * [ ] [html_entity_decode](http://php.net/manual/en/function.html-entity-decode.php) — Convert HTML entities to their corresponding characters 432 | * [ ] [htmlentities](http://php.net/manual/en/function.htmlentities.php) — Convert all applicable characters to HTML entities 433 | * [ ] [htmlspecialchars_decode](http://php.net/manual/en/function.htmlspecialchars-decode.php) — Convert special HTML entities back to characters 434 | * [ ] [htmlspecialchars](http://php.net/manual/en/function.htmlspecialchars.php) — Convert special characters to HTML entities 435 | * [x] [implode](http://php.net/manual/en/function.implode.php) — Join array elements with a string 436 | * [x] [join](http://php.net/manual/en/function.join.php) — Alias of implode 437 | * [x] [lcfirst](http://php.net/manual/en/function.lcfirst.php) — Make a string's first character lowercase 438 | * [x] [levenshtein](http://php.net/manual/en/function.levenshtein.php) — Calculate Levenshtein distance between two strings 439 | * [ ] [localeconv](http://php.net/manual/en/function.localeconv.php) — Get numeric formatting information 440 | * [x] [ltrim](http://php.net/manual/en/function.ltrim.php) — Strip whitespace (or other characters) from the beginning of a string 441 | * [x] [md5_file](http://php.net/manual/en/function.md5-file.php) — Calculates the md5 hash of a given file 442 | * [x] [md5](http://php.net/manual/en/function.md5.php) — Calculate the md5 hash of a string 443 | * [ ] [metaphone](http://php.net/manual/en/function.metaphone.php) — Calculate the metaphone key of a string 444 | * [ ] [money_format](http://php.net/manual/en/function.money-format.php) — Formats a number as a currency string 445 | * [ ] [nl_langinfo](http://php.net/manual/en/function.nl-langinfo.php) — Query language and locale information 446 | * [x] [nl2br](http://php.net/manual/en/function.nl2br.php) — Inserts HTML line breaks before all newlines in a string 447 | * [x] [number_format](http://php.net/manual/en/function.number-format.php) — Format a number with grouped thousands 448 | * [ ] [ord](http://php.net/manual/en/function.ord.php) — Convert the first byte of a string to a value between 0 and 255, `Built-in function in Python` 449 | * [ ] [parse_str](http://php.net/manual/en/function.parse-str.php) — Parses the string into variables 450 | * [ ] [print](http://php.net/manual/en/function.print.php) — Output a string, `Built-in function in Python` 451 | * [x] [printf](http://php.net/manual/en/function.printf.php) — Output a formatted string 452 | * [ ] [quoted_printable_decode](http://php.net/manual/en/function.quoted-printable-decode.php) — Convert a quoted-printable string to an 8 bit string 453 | * [ ] [quoted_printable_encode](http://php.net/manual/en/function.quoted-printable-encode.php) — Convert a 8 bit string to a quoted-printable string 454 | * [ ] [quotemeta](http://php.net/manual/en/function.quotemeta.php) — Quote meta characters 455 | * [x] [rtrim](http://php.net/manual/en/function.rtrim.php) — Strip whitespace (or other characters) from the end of a string 456 | * [ ] [setlocale](http://php.net/manual/en/function.setlocale.php) — Set locale information 457 | * [x] [sha1_file](http://php.net/manual/en/function.sha1-file.php) — Calculate the sha1 hash of a file 458 | * [x] [sha1](http://php.net/manual/en/function.sha1.php) — Calculate the sha1 hash of a string 459 | * [ ] [similar_text](http://php.net/manual/en/function.similar-text.php) — Calculate the similarity between two strings 460 | * [ ] [soundex](http://php.net/manual/en/function.soundex.php) — Calculate the soundex key of a string 461 | * [ ] [sprintf](http://php.net/manual/en/function.sprintf.php) — Return a formatted string 462 | * [ ] [sscanf](http://php.net/manual/en/function.sscanf.php) — Parses input from a string according to a format 463 | * [x] [str_getcsv](http://php.net/manual/en/function.str-getcsv.php) — Parse a CSV string into an array 464 | * [x] [str_ireplace](http://php.net/manual/en/function.str-ireplace.php) — Case-insensitive version of str_replace 465 | * [x] [str_pad](http://php.net/manual/en/function.str-pad.php) — Pad a string to a certain length with another string 466 | * [x] [str_repeat](http://php.net/manual/en/function.str-repeat.php) — Repeat a string 467 | * [x] [str_replace](http://php.net/manual/en/function.str-replace.php) — Replace all occurrences of the search string with the replacement string 468 | * [x] [str_rot13](http://php.net/manual/en/function.str-rot13.php) — Perform the rot13 transform on a string 469 | * [x] [str_shuffle](http://php.net/manual/en/function.xtr-shuffle.php) — Randomly shuffles a string 470 | * [x] [str_split](http://php.net/manual/en/function.str-split.php) — Convert a string to an array 471 | * [x] [str_word_count](http://php.net/manual/en/function.str-word-count.php) — Return information about words used in a string 472 | * [ ] [strcasecmp](http://php.net/manual/en/function.strcasecmp.php) — Binary safe case-insensitive string comparison 473 | * [x] [strchr](http://php.net/manual/en/function.strchr.php) — Alias of strstr 474 | * [x] [strcmp](http://php.net/manual/en/function.strcmp.php) — Binary safe string comparison 475 | * [ ] [strcoll](http://php.net/manual/en/function.strcoll.php) — Locale based string comparison 476 | * [x] [strcspn](http://php.net/manual/en/function.strcspn.php) — Find length of initial segment not matching mask 477 | * [ ] [strip_tags](http://php.net/manual/en/function.strip-tags.php) — Strip HTML and PHP tags from a string 478 | * [ ] [stripcslashes](http://php.net/manual/en/function.stripcslashes.php) — Un-quote string quoted with addcslashes 479 | * [x] [stripos](http://php.net/manual/en/function.stripos.php) — Find the position of the first occurrence of a case-insensitive substring in a string 480 | * [ ] [stripslashes](http://php.net/manual/en/function.stripslashes.php) — Un-quotes a quoted string 481 | * [x] [stristr](http://php.net/manual/en/function.stristr.php) — Case-insensitive strstr 482 | * [x] [strlen](http://php.net/manual/en/function.strlen.php) — Get string length 483 | * [ ] [strnatcasecmp](http://php.net/manual/en/function.strnatcasecmp.php) — Case insensitive string comparisons using a "natural order" algorithm 484 | * [ ] [strnatcmp](http://php.net/manual/en/function.strnatcmp.php) — String comparisons using a "natural order" algorithm 485 | * [ ] [strncasecmp](http://php.net/manual/en/function.strncasecmp.php) — Binary safe case-insensitive string comparison of the first n characters 486 | * [ ] [strncmp](http://php.net/manual/en/function.strncmp.php) — Binary safe string comparison of the first n characters 487 | * [x] [strpbrk](http://php.net/manual/en/function.strpbrk.php) — Search a string for any of a set of characters 488 | * [x] [strpos](http://php.net/manual/en/function.strpos.php) — Find the position of the first occurrence of a substring in a string 489 | * [x] [strrchr](http://php.net/manual/en/function.strrchr.php) — Find the last occurrence of a character in a string 490 | * [x] [strrev](http://php.net/manual/en/function.strrev.php) — Reverse a string 491 | * [x] [strripos](http://php.net/manual/en/function.strripos.php) — Find the position of the last occurrence of a case-insensitive substring in a string 492 | * [x] [strrpos](http://php.net/manual/en/function.strrpos.php) — Find the position of the last occurrence of a substring in a string 493 | * [x] [strspn](http://php.net/manual/en/function.strspn.php) — Finds the length of the initial segment of a string consisting entirely of characters contained within a given mask 494 | * [x] [strstr](http://php.net/manual/en/function.strstr.php) — Find the first occurrence of a string 495 | * [ ] [strtok](http://php.net/manual/en/function.strtok.php) — Tokenize string 496 | * [x] [strtolower](http://php.net/manual/en/function.strtolower.php) — Make a string lowercase 497 | * [x] [strtoupper](http://php.net/manual/en/function.strtoupper.php) — Make a string uppercase 498 | * [x] [strtr](http://php.net/manual/en/function.strtr.php) — Translate characters or replace substrings 499 | * [ ] [substr_compare](http://php.net/manual/en/function.substr-compare.php) — Binary safe comparison of two strings from an offset, up to length characters 500 | * [x] [substr_count](http://php.net/manual/en/function.substr-count.php) — Count the number of substring occurrences 501 | * [x] [substr_replace](http://php.net/manual/en/function.substr-replace.php) — Replace text within a portion of a string 502 | * [x] [substr](http://php.net/manual/en/function.substr.php) — Return part of a string 503 | * [x] [trim](http://php.net/manual/en/function.trim.php) — Strip whitespace (or other characters) from the beginning and end of a string 504 | * [x] [ucfirst](http://php.net/manual/en/function.ucfirst.php) — Make a string's first character uppercase 505 | * [x] [ucwords](http://php.net/manual/en/function.ucwords.php) — Uppercase the first character of each word in a string 506 | * [ ] [vfprintf](http://php.net/manual/en/function.vfprintf.php) — Write a formatted string to a stream 507 | * [ ] [vprintf](http://php.net/manual/en/function.vprintf.php) — Output a formatted string 508 | * [ ] [vsprintf](http://php.net/manual/en/function.vsprintf.php) — Return a formatted string 509 | * [x] [wordwrap](http://php.net/manual/en/function.wordwrap.php) — Wraps a string to a given number of characters 510 | 511 | ## URL Functions 512 | 513 |
514 | ↥ back to top 515 |
516 | 517 | * [x] [base64_decode](http://php.net/manual/en/function.base64-decode.php) — Decodes data encoded with MIME base64 518 | * [x] [base64_encode](http://php.net/manual/en/function.base64-encode.php) — Encodes data with MIME base64 519 | * [x] [get_headers](http://php.net/manual/en/function.get-headers.php) — Fetches all the headers sent by the server in response to an HTTP request 520 | * [x] [get_meta_tags](http://php.net/manual/en/function.get-meta-tags.php) — Extracts all meta tag content attributes from a file and returns an array 521 | * [x] [http_build_query](http://php.net/manual/en/function.http-build-query.php) — Generate URL-encoded query string 522 | * [x] [parse_url](http://php.net/manual/en/function.parse-url.php) — Parse a URL and return its components 523 | * [x] [rawurldecode](http://php.net/manual/en/function.rawurldecode.php) — Decode URL-encoded strings 524 | * [x] [rawurlencode](http://php.net/manual/en/function.rawurlencode.php) — URL-encode according to RFC 3986 525 | * [x] [urldecode](http://php.net/manual/en/function.urldecode.php) — Decodes URL-encoded string 526 | * [x] [urlencode](http://php.net/manual/en/function.urlencode.php) — URL-encodes string 527 | 528 | ## Variable handling Functions 529 | 530 |
531 | ↥ back to top 532 |
533 | 534 | * [x] [boolval](http://php.net/manual/en/function.boolval.php) — Get the boolean value of a variable 535 | * [ ] [debug_zval_dump](http://php.net/manual/en/function.debug-zval-dump.php) — Dumps a string representation of an internal zend value to output 536 | * [x] [doubleval](http://php.net/manual/en/function.doubleval.php) — Alias of floatval 537 | * [x] [empty](http://php.net/manual/en/function.empty.php) — Determine whether a variable is empty 538 | * [x] [floatval](http://php.net/manual/en/function.floatval.php) — Get float value of a variable 539 | * [ ] [get_defined_vars](http://php.net/manual/en/function.get-defined-vars.php) — Returns an array of all defined variables 540 | * [ ] [get_resource_type](http://php.net/manual/en/function.get-resource-type.php) — Returns the resource type 541 | * [x] [gettype](http://php.net/manual/en/function.gettype.php) — Get the type of a variable 542 | * [ ] [import_request_variables](http://php.net/manual/en/function.import-request-variables.php) — Import GET/POST/Cookie variables into the global scope 543 | * [x] [intval](http://php.net/manual/en/function.intval.php) — Get the integer value of a variable 544 | * [x] [is_array](http://php.net/manual/en/function.is-array.php) — Finds whether a variable is an array 545 | * [x] [is_bool](http://php.net/manual/en/function.is-bool.php) — Finds out whether a variable is a boolean 546 | * [x] [is_callable](http://php.net/manual/en/function.is-callable.php) — Verify that the contents of a variable can be called as a function 547 | * [x] [is_countable](http://php.net/manual/en/function.is-countable.php) — Verify that the contents of a variable is a countable value 548 | * [x] [is_double](http://php.net/manual/en/function.is-double.php) — Alias of is_float 549 | * [x] [is_float](http://php.net/manual/en/function.is-float.php) — Finds whether the type of a variable is float 550 | * [x] [is_int](http://php.net/manual/en/function.is-int.php) — Find whether the type of a variable is integer 551 | * [x] [is_integer](http://php.net/manual/en/function.is-integer.php) — Alias of is_int 552 | * [x] [is_iterable](http://php.net/manual/en/function.is-iterable.php) — Verify that the contents of a variable is an iterable value 553 | * [x] [is_long](http://php.net/manual/en/function.is-long.php) — Alias of is_int 554 | * [x] [is_null](http://php.net/manual/en/function.is-null.php) — Finds whether a variable is NULL 555 | * [x] [is_numeric](http://php.net/manual/en/function.is-numeric.php) — Finds whether a variable is a number or a numeric string 556 | * [x] [is_object](http://php.net/manual/en/function.is-object.php) — Finds whether a variable is an object 557 | * [x] [is_real](http://php.net/manual/en/function.is-real.php) — Alias of is_float 558 | * [ ] [is_resource](http://php.net/manual/en/function.is-resource.php) — Finds whether a variable is a resource 559 | * [x] [is_scalar](http://php.net/manual/en/function.is-scalar.php) — Finds whether a variable is a scalar 560 | * [x] [is_string](http://php.net/manual/en/function.is-string.php) — Find whether the type of a variable is string 561 | * [x] [isset](http://php.net/manual/en/function.isset.php) — Determine if a variable is set and is not NULL 562 | * [x] [print_r](http://php.net/manual/en/function.print-r.php) — Prints human-readable information about a variable 563 | * [x] [serialize](http://php.net/manual/en/function.serialize.php) — Generates a storable representation of a value 564 | * [ ] [settype](http://php.net/manual/en/function.settype.php) — Set the type of a variable 565 | * [x] [strval](http://php.net/manual/en/function.strval.php) — Get string value of a variable 566 | * [ ] [unserialize](http://php.net/manual/en/function.unserialize.php) — Creates a PHP value from a stored representation 567 | * [x] [unset](http://php.net/manual/en/function.unset.php) — Unset a given variable 568 | * [x] [var_dump](http://php.net/manual/en/function.var-dump.php) — Dumps information about a variable 569 | * [x] [var_export](http://php.net/manual/en/function.var-export.php) — Outputs or returns a parsable string representation of a variable --------------------------------------------------------------------------------