title: Why we use mysqli_init() and mysqli_real_connect() if we have mysqli_connect() function in php?
body: <p>I am new to php and doing some experiments on the following three functions:</p>
  
  <ol>
  <li><strong>mysqli_connect()</strong></li>
  <li><strong>mysqli_real_connect()</strong></li>
  <li><strong>mysqli_init()</strong></li>
  </ol>
  
  <p>As we know that PHP provides two ways to connect to mysql server.</p>
  
  <ol>
  <li><strong>Object Oriented mysqli class</strong></li>
  <li><strong>Procedural mysqli</strong></li>
  </ol>
  
  <p><strong>Question one:</strong> When we do something like that</p>
  
  <pre><code>$mysqli = new mysqli('host','username','password','database');
  </code></pre>
  
  <p>It means we started connection to mysql server, so why then using the following statement even we already connected the mysql database server.</p>
  
  <pre><code>$mysqli-&gt;init(void);
  </code></pre>
  
  <p><strong>Question two:</strong> When we do something like that</p>
  
  <pre><code>mysqli_init(void);
  </code></pre>
  
  <p>So, whether it automatically get the mysql object ? Should we use <strong>mysqli_connect()</strong> function before it or it automatically generates mysql server object internally by php ? Should we call this <strong>mysqli_init()</strong> function without any <strong>mysqli_connect()</strong> function ? Whether <strong>mysqli_init()</strong> automatically gets the mysql server object internally ?</p>
  
  <p><strong>Question three:</strong></p>
  
  <p>When we have</p>
  
  <pre><code>mysqli_connect();
  </code></pre>
  
  <p>then why we use</p>
  
  <pre><code>mysqli_init();
  </code></pre>
  
  <p>and</p>
  
  <pre><code>mysqli_real_connect();
  </code></pre>
  
  <p>Why php added the <strong>mysqli_init()</strong> and <strong>mysqli_real_connect()</strong> function even <strong>mysqli_connect()</strong> is available ? Where the <strong>mysqli_init()</strong> and <strong>mysqli_real_connect()</strong> functions are useful instead of <strong>mysqli_connect()</strong> ?</p>
  
  <p>What is the difference between them ?</p>
  
  <p>Can anyone tell ?</p>
  
  <p>Thanks in advance !!!</p>