Use echo
for functions that return values (e.g., esc_url(get_permalink())
).
Don’t use echo
for functions that output directly (e.g., the_permalink()
).
Always escape output (e.g., esc_url()
, esc_html()
) to prevent XSS attacks.
Prefer return functions (e.g., get_permalink()
) over output functions (e.g., the_permalink()
) for better control.
Correct Example:
<a href="<?php echo esc_url(get_permalink()); ?>">link</a>
This ensures security and proper functionality. Thanks