@@ -501,31 +501,23 @@ function strcoll(string $string1, string $string2): int {}
501501function money_format (string $ format , float $ number ): ?string {}
502502
503503/**
504- * Return part of a string or false on failure. For PHP8.0+ only string is returned
504+ * Returns the portion of string specified by the offset and length parameters.
505505 * @link https://php.net/manual/en/function.substr.php
506506 * @param string $string <p>
507507 * The input string.
508508 * </p>
509509 * @param int $offset <p>
510- * If start is non-negative, the returned string
511- * will start at the start'th position in
512- * string, counting from zero. For instance,
513- * in the string 'abcdef', the character at
514- * position 0 is 'a', the
515- * character at position 2 is
516- * 'c', and so forth.
510+ * If offset is non-negative, the returned string will start at the offset'th position in string, counting from zero.
511+ * For instance, in the string 'abcdef', the character at position 0 is 'a', the character at position 2 is 'c', and so forth.
517512 * </p>
518513 * <p>
519- * If start is negative, the returned string
520- * will start at the start'th character
521- * from the end of string.
514+ * If offset is negative, the returned string will start at the offset'th character from the end of string.
522515 * </p>
523516 * <p>
524- * If string is less than or equal to
525- * start characters long, false will be returned.
517+ * If string is less than offset characters long, an empty string will be returned.
526518 * </p>
527519 * <p>
528- * Using a negative start
520+ * Using a negative offset
529521 * </p>
530522 * <pre>
531523 * <?php
@@ -535,24 +527,22 @@ function money_format(string $format, float $number): ?string {}
535527 * ?>
536528 * </pre>
537529 * @param int|null $length [optional] <p>
538- * If length is given and is positive, the string
539- * returned will contain at most length characters
540- * beginning from start (depending on the length of
541- * string).
530+ * If length is given and is positive, the string returned will contain at most length characters beginning from offset
531+ * (depending on the length of string).
542532 * </p>
543533 * <p>
544- * If length is given and is negative, then that many
545- * characters will be omitted from the end of string
546- * (after the start position has been calculated when a
547- * start is negative). If
548- * start denotes a position beyond this truncation,
549- * an empty string will be returned.
534+ * If length is given and is negative, then that many characters will be omitted from the end of string.
535+ * If offset denotes the position of this truncation or beyond, an empty string will be returned.
550536 * </p>
551537 * <p>
552- * If length is given and is 0,
553- * false or null an empty string will be returned.
538+ * If length is given and is 0, an empty string will be returned.
554539 * </p>
540+ * <p>
541+ * Starting from PHP 8.0 if length is omitted or null, the substring starting from offset until the end of the string will be returned.
542+ * </p>
543+ * <p>
555544 * Using a negative length:
545+ * </p>
556546 * <pre>
557547 * <?php
558548 * $rest = substr("abcdef", 0, -1); // returns "abcde"
@@ -561,6 +551,25 @@ function money_format(string $format, float $number): ?string {}
561551 * $rest = substr("abcdef", -3, -1); // returns "de"
562552 * ?>
563553 * </pre>
554+ * @return string|false Returns the extracted part of string, or an empty string. (FALSE prior PHP 8.0)
555+ * <p>
556+ * Basic usage:
557+ * </p>
558+ * <code>
559+ * echo substr('abcdef', 1), PHP_EOL; // bcdef
560+ * echo substr("abcdef", 1, null), PHP_EOL; // bcdef; prior to PHP 8.0.0, empty string was returned
561+ * echo substr('abcdef', 1, 3), PHP_EOL; // bcd
562+ * echo substr('abcdef', 0, 4), PHP_EOL; // abcd
563+ * echo substr('abcdef', 0, 8), PHP_EOL; // abcdef
564+ * echo substr('abcdef', -1, 1), PHP_EOL; // f
565+ *
566+ * // Accessing single characters in a string
567+ * // can also be achieved using "square brackets"
568+ * $string = 'abcdef';
569+ * echo $string[0], PHP_EOL; // a
570+ * echo $string[3], PHP_EOL; // d
571+ * echo $string[strlen($string)-1], PHP_EOL; // f
572+ * </code>
564573 */
565574#[Pure]
566575#[LanguageLevelTypeAware(["8.0 " => "string " ], default: "string|false " )]
@@ -699,17 +708,12 @@ function addslashes(string $string): string {}
699708 * The string to be escaped.
700709 * </p>
701710 * @param string $characters <p>
702- * A list of characters to be escaped. If
703- * charlist contains characters
704- * \n, \r etc., they are
705- * converted in C-like style, while other non-alphanumeric characters
706- * with ASCII codes lower than 32 and higher than 126 converted to
707- * octal representation.
711+ * A list of characters to be escaped. If characters contains characters \n, \r etc., they are converted in C-like style,
712+ * while other non-alphanumeric characters with ASCII codes lower than 32 and higher than 126 converted to octal representation.
708713 * </p>
709714 * <p>
710- * When you define a sequence of characters in the charlist argument
711- * make sure that you know what characters come between the
712- * characters that you set as the start and end of the range.
715+ * When you define a sequence of characters in the characters argument make sure that you know what characters come
716+ * between the characters that you set as the start and end of the range.
713717 * </p>
714718 * <pre>
715719 * <?php
@@ -733,14 +737,23 @@ function addslashes(string $string): string {}
733737 * ?>
734738 * </pre>
735739 * <p>
736- * Be careful if you choose to escape characters 0, a, b, f, n, r,
737- * t and v. They will be converted to \0, \a, \b, \f, \n, \r, \t
738- * and \v.
739- * In PHP \0 (NULL), \r (carriage return), \n (newline), \f (form feed),
740- * \v (vertical tab) and \t (tab) are predefined escape sequences,
741- * while in C all of these are predefined escape sequences.
740+ * Be careful if you choose to escape characters 0, a, b, f, n, r, t and v.
741+ * They will be converted to \0, \a, \b, \f, \n, \r, \t and \v, all of which are predefined escape sequences in C.
742+ * Many of these sequences are also defined in other C-derived languages, including PHP, meaning that you may not get
743+ * the desired result if you use the output of addcslashes() to generate code in those languages with these characters
744+ * defined in characters.
742745 * </p>
743746 * @return string the escaped string.
747+ * <p>
748+ * Example usage:
749+ * </p>
750+ * <code>
751+ * <?php
752+ * $not_escaped = "PHP isThirty\nYears Old!\tYay to the Elephant!\n";
753+ * $escaped = addcslashes($not_escaped, "\0..\37!@\177..\377");
754+ * echo $escaped;
755+ * ?>
756+ * </code>
744757 */
745758#[Pure]
746759function addcslashes (string $ string , string $ characters ): string {}
0 commit comments