<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Creates a new class instance from given arguments.</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="reflectionclass.isuserdefined.html">ReflectionClass::isUserDefined</a></div> <div class="next" style="text-align: right; float: right;"><a href="reflectionclass.newinstanceargs.html">ReflectionClass::newInstanceArgs</a></div> <div class="up"><a href="class.reflectionclass.html">ReflectionClass</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="reflectionclass.newinstance" class="refentry"> <div class="refnamediv"> <h1 class="refname">ReflectionClass::newInstance</h1> <p class="verinfo">(PHP 5)</p><p class="refpurpose"><span class="refname">ReflectionClass::newInstance</span> — <span class="dc-title">Creates a new class instance from given arguments.</span></p> </div> <div class="refsect1 description" id="refsect1-reflectionclass.newinstance-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type">object</span> <span class="methodname"><strong>ReflectionClass::newInstance</strong></span> ( <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$args</code></span> [, <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$...</code></span> ] )</div> <p class="para rdfs-comment"> Creates a new instance of the class. The given arguments are passed to the class constructor. </p> </div> <div class="refsect1 parameters" id="refsect1-reflectionclass.newinstance-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">args</code></em></span> <dd> <p class="para"> Accepts a variable number of arguments which are passed to the class constructor, much like <span class="function"><a href="function.call-user-func.html" class="function">call_user_func()</a></span>. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-reflectionclass.newinstance-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> </p> </div> <div class="refsect1 errors" id="refsect1-reflectionclass.newinstance-errors"> <h3 class="title">Errors/Exceptions</h3> <p class="para"> A <a href="class.reflectionexception.html" class="classname">ReflectionException</a> if the class constructor is not public. </p> <p class="para"> A <a href="class.reflectionexception.html" class="classname">ReflectionException</a> if the class does not have a constructor and the <em><code class="parameter">args</code></em> parameter contains one or more parameters. </p> </div> <div class="refsect1 seealso" id="refsect1-reflectionclass.newinstance-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="methodname"><a href="reflectionclass.newinstanceargs.html" class="methodname" rel="rdfs-seeAlso">ReflectionClass::newInstanceArgs()</a> - Creates a new class instance from given arguments.</span></li> <li class="member"> <span class="methodname"><a href="reflectionclass.newinstancewithoutconstructor.html" class="methodname" rel="rdfs-seeAlso">ReflectionClass::newInstanceWithoutConstructor()</a> - Creates a new class instance without invoking the constructor.</span></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="reflectionclass.isuserdefined.html">ReflectionClass::isUserDefined</a></div> <div class="next" style="text-align: right; float: right;"><a href="reflectionclass.newinstanceargs.html">ReflectionClass::newInstanceArgs</a></div> <div class="up"><a href="class.reflectionclass.html">ReflectionClass</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>