In the above example the %s will be replaced by the value of $myString to create a string which reads: Let's begin by embedding a string variable into a PHP printf function call: The following table lists the variable types and the corresponding letter to use when constructing the formatting rule:ĪDSDAQBOX_FLOW Specifier Description %% Displays a percent sign %b A integer represented as a binary number %c A character based on the ASCII value %d A signed decimal number %e Scientific notation (for example 1.2e+2) %u An unsigned decimal number %f A floating-point number %F Floating-point number %o An octal number %s A String %x Hexadecimal number in lowercase letters %X Hexadecimal number in uppercase lettersīefore we look at the formatting options we first need to see some of the above rules in action. Optional rules can be placed between the '%' and the type letter to control formatting. For example, a string is represented by %s. The formatting specifiers begin with a '%' character following by a letter to indicate the type of variable to be displayed. When executed the above code will produce the following output: The ASCII code for A is 65 The following example converts a character to an ASCII code and then reverts it back to the character: ' Įcho "The character for ASCII code for $asciicode is ".
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |