# [Discussion] Proposal: get_favicon() helper function

- Thread: https://externals.io/message/131282
- Original archive: https://news-web.php.net/php.internals/131282
- Started by sepehrphpr@gmail.com on 2026-06-15T15:35:15+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #131282 — sepehrphpr@gmail.com — 2026-06-15T15:35:15+00:00

URL: https://externals.io/message/131282#131282

Hi internals,

My name is Sepehr and I would like to propose a small helper function for
PHP that extracts the favicon URL of a given page.

The function takes a URL, fetches the HTML, and returns the favicon URL as
a string.

Possible signature:

get_favicon(string $url): ?string

The function would scan the HTML for common favicon declarations such as:

<link rel=“icon” href=“…”>

<link rel=“shortcut icon” href=“…”>

<link rel=“apple-touch-icon” href=“…”>

If a favicon link is found, the function returns the URL. If not, it
returns null.

The goal is to provide a simple built-in helper for a common task in web
utilities and crawlers.

I would appreciate feedback on this. If it seems reasonable, I’d like to
draft an RFC and request a wiki account to create the proposal page.

Best regards,


Sepehr

---

## #131283 — kasper Sanguesa-Franz — 2026-06-15T16:09:01+00:00

URL: https://externals.io/message/131282#131283 · In reply to: #131282



---

## #131287 — Kamil Tekiela — 2026-06-15T17:22:26+00:00

URL: https://externals.io/message/131282#131287 · In reply to: #131282

> Hi internals,
>
> My name is Sepehr and I would like to propose a small helper function for
> PHP that extracts the favicon URL of a given page.
>
> The function takes a URL, fetches the HTML, and returns the favicon URL as
> a string.
>
> Possible signature:
>
> get_favicon(string $url): ?string
>
> The function would scan the HTML for common favicon declarations such as:
>
> <link rel=“icon” href=“…”>
>
> <link rel=“shortcut icon” href=“…”>
>
> <link rel=“apple-touch-icon” href=“…”>
>
> If a favicon link is found, the function returns the URL. If not, it
> returns null.
>
> The goal is to provide a simple built-in helper for a common task in web
> utilities and crawlers.
>
> I would appreciate feedback on this. If it seems reasonable, I’d like to
> draft an RFC and request a wiki account to create the proposal page.
>
> Best regards,
>
>
> Sepehr
>


Why is that a common thing so much that it needs to be part of the
language? Why can't you do it with existing Dom tools? Why does it have to
return null? Why does it take URL as an argument and simingly also return
it as well? Where does it fetch the HTML from? Does it do a http request
too?
