Live page truncated to 30 bytes

Содержание
Symptom
Ruled out
Root cause
Fix

Symptom

A page returned HTTP 200 with a 30-byte body on hosting while the same page rendered fully locally. Error display is off on hosting, so the browser showed a silent truncation instead of the fatal.

Ruled out

  1. Stale files: a probe reporting md5_file() of every involved class proved all 8 hashes identical to the repo.
  2. OPcache: a probe running opcache_invalidate() on 12 files reported success — the page still truncated.

Root cause

src/.php is a symlink to src/ao/.php locally (one inode), but the FTP deploy resolves symlinks into two real directories. One page loaded the same helper through both spellings, and require_once — which dedupes by path, not by inode across machines — loaded it twice:

Fatal error: Cannot redeclare get_urls()

Unreproducible locally by design: the two paths can never diverge while linked.

Fix

Guard the definition so the second load is a no-op:

if (!function_exists('get_urls')) { function get_urls(...$numbers) { ... } } // function_exists('get_urls')

The hosting error log named file and line outright — it is always the first place to look. A repo-wide scan found 9 files requiring their own twin path; 8 were commented out, only this one executed.

Article author: Andrei Olegovich

Похожие статьи
Development with PHP
PHP errors: case studies
Top menu disappeared
Live page truncated to 30 bytes
Cannot redeclare get_urls()

Поиск по сайту

Канал @aofeed Чат @aofeedchat

Контакты и сотрудничество:
Рекомендую наш хостинг beget.ru
Пишите на info@urn.su если Вы:
1. Хотите написать статью для нашего сайта или перевести статью на свой родной язык.
2. Хотите разместить на сайте рекламу, подходящую по тематике.
3. Реклама на моём сайте имеет максимальный уровень цензуры. Если Вы увидели рекламный блок недопустимый для просмотра детьми школьного возраста, вызывающий шок или вводящий в заблуждение - пожалуйста свяжитесь с нами по электронной почте
4. Нашли на сайте ошибку, неточности, баг и т.д. ... .......
5. Статьи можно расшарить в соцсетях, нажав на иконку сети: