PHPBot — practical PHP guides and a JSON formatter
PHPBot helps PHP developers understand code, handle JSON and check everyday implementation choices with worked examples and a browser-based formatter.
Choose a pattern for the change you need
Observer lets other objects respond when state changes. Strategy lets you swap one way of doing a job for another. Use Decorator when you want to wrap an object and add behaviour while keeping its interface. The pattern guide works through those choices in a notification example.
Format JSON or decode it in PHP
Use the browser formatter to indent JSON or remove its insignificant whitespace. It keeps numeric spellings such as -0 and preserves duplicate keys in the text.
When decoding JSON in PHP, use JSON_BIGINT_AS_STRING if an integer literal can exceed the platform’s integer range. The decoded value becomes a string. Encoding it again gives you a quoted JSON value, which matters if the receiver expects a number.
Display text safely in HTML
The escaping guide shows how htmlspecialchars() handles text nodes and ordinary quoted attributes. Check where the value goes before choosing an escaping method. A URL, script or style context needs separate handling.
