MaplePHP
  • MaplePHP - Layered structure MVC PHP framework
  • Guide
    • Get started
    • Installation
    • Service Provider
    • Dependency injector
    • Controller
    • Middlewares
    • Routers
  • Navigation
    • Simple navigation
    • Dynamic navigation
  • Template engine
    • Getting started
    • Templates
      • Index
      • Views
      • Partials
    • Content (DTO)
      • String
      • Number
      • Array
      • DateTime
      • Encode
      • Dom
  • Form builder
    • Form builder
  • Database
    • MySQL
  • Service providers
    • url
    • encode
    • dir
    • DB
    • responder
  • Installations
    • Authorization & login
  • Frontend template
    • Responder
    • Views & components
    • Modals
    • Redirects
  • Access
    • MaplePHP with Docker
  • Libraries
    • Container
    • MySQL queries
    • Validation
    • Cache
    • Logger
    • Request
    • Response
  • What is?
    • Dependency injector
    • Controller
    • Middleware
    • Router
Powered by GitBook
On this page
  • MaplePHP Encode Library
  • Encoding Configuration Methods
  • Encoding Methods
  • Properties

Was this helpful?

  1. Template engine
  2. Content (DTO)

Encode

MaplePHP Encode Library

This PHP library, named MaplePHP\DTO\Format\Encode, provides functionality for encoding data, including JSON encoding, URL encoding, and special character encoding.

Encoding Configuration Methods

urlEncode(bool $encode): self

  • Sets the URL encoding flag.

  • Parameters:

    • $encode: If true, URL encoding will be applied; otherwise, it will be skipped.

  • Returns:

    • An instance of the encoding object.

specialChar(bool $encode, int $flag = ENT_NOQUOTES): self

  • Sets the special character encoding flag.

  • Parameters:

    • $encode: If true, special character encoding will be applied; otherwise, it will be skipped.

    • $flag: The flag for special character encoding.

  • Returns:

    • An instance of the encoding object.

Encoding Methods

encode(?callable $callback = null): string|array

  • Encodes the value according to the specified encoding configurations.

  • Parameters:

    • $callback: Optional callback to access the encoded value and modify it further.

  • Returns:

    • The encoded value as a string or array.

urldecode(?callable $callback = null): string|array

  • Decodes the URL-encoded value.

  • Parameters:

    • $callback: Optional callback to access the decoded value and modify it further.

  • Returns:

    • The URL-decoded value as a string or array.

xss(?callable $callback = null): self

  • Applies special character encoding to protect against cross-site scripting (XXS).

  • Parameters:

    • $callback: Optional callback to access the encoded value and modify it further.

  • Returns:

    • An instance of the encoding object with special character encoding applied.

Properties

  • $jsonEncode: A boolean indicating whether JSON encoding is enabled.

  • $specialChar: A boolean indicating whether special character encoding is enabled.

  • $specialCharFlag: The flag for special character encoding.

  • $urlencode: A boolean indicating whether URL encoding is enabled.

PreviousDateTimeNextDom

Last updated 1 year ago

Was this helpful?