@strlen & @trim - String Length and Trimming
The @strlen and @trim directives in Ahmed PHP Template Engine allow you to work with string lengths and remove whitespace.
Syntax
@strlen(stringValue)
@trim(stringValue)stringValue: The string to be processed.
Description
@strlenreturns the length of a string (number of characters).@trimremoves whitespace from the beginning and end of a string.Useful for text processing, validation, and formatting.
Example
Get String Length
@var(name, "Ahmed")
<p>Length: @strlen(name)</p>Expected Output:
<p>Length: 5</p>Trim Whitespace
Expected Output:
Notes
@strlendoes not count whitespace separately.@trimis useful for cleaning up user input before processing.Works with variables and direct string values.
Last updated