wireClassName() function

Normalize a class name with or without namespace, or get namespace of class

Default behavior is to return class name without namespace.

Usage

// basic usage
$string = wireClassName($className);

// usage with all arguments
$string = wireClassName($className, $withNamespace = false, bool $verbose = false);

Arguments

NameType(s)Description
classNamestring, object

Class name or object instance

withNamespace (optional)bool, int, string

Should return value include namespace? (default=false)

  • false (bool): Return only class name without namespace (default).
  • true (bool): Yes include namespace in returned value.
  • 1 (int): Return only namespace (i.e. “ProcessWire”, with no backslashes unless $verbose argument is true)
verbose (optional)bool

When namespace argument is true or 1, use verbose return value (added 3.0.143). This does the following:

  • If returning class name with namespace, this makes it include a leading backslash, i.e. \ProcessWire\Wire
  • If returning namespace only, adds leading backslash, plus trailing backslash if namespace is not root, i.e. \ProcessWire\

Return value

string null

Returns string or NULL if namespace-only requested and unable to determine


Functions methods and properties

API reference based on ProcessWire core version 3.0.236

Latest news

  • ProcessWire Weekly #543
    In the 543rd issue of ProcessWire Weekly we'll check out the latest weekly update from Ryan, introduce a couple of new third party modules — both authored by Bernhard Baumrock — and more. Read on!
    Weekly.pw / 5 October 2024
  • Custom Fields Module
    This week we look at a new ProFields module named Custom Fields. This module provides a way to rapidly build out ProcessWire fields that contain any number of subfields/properties within them.
    Blog / 30 August 2024
  • Subscribe to weekly ProcessWire news

“Yesterday I sent the client a short documentation for their ProcessWire-powered website. Today all features already used with no questions. #cmsdoneright—Marc Hinse, Web designer/developer