title: Can't connect to FTP server through Apache + PHP webserver because of unrecognized PHP function (ftp_connect)
body: <p>the title is a bit self-explanatory, here are the details:</p>
  
  <p>I'm running a webserver installed on a laptop with Windows 10 Pro x64, with <strong>Apache 2.4</strong> and <strong>PHP 7.1.8</strong> VC14 for x64 <em>(from Apache Lounge)</em> <strong>installed as an Apache module</strong> and running as Windows service, everything installed manually and separately.</p>
  
  <p><em>(I'm also using PHP for comunicating with a MySQL database, but this is out of the scope of this problem.)</em></p>
  
  <p>So everything has been perfect until I decided to incorporate a <strong>FTP server</strong> for offering a file library service through the website with FileZilla Server. <em>(In the same machine)</em></p>
  
  <hr>
  
  <p>The problem is, <strong>PHP is unwilling to recognize the ftp_connect() PHP function</strong>.</p>
  
  <p>This is the PHP code I'm trying to run:</p>
  
  <pre><code>    try {
  
          // Create the connection.
          $conftp = ftp_connect('myhostname');
  
      } catch (Error $ex) {
  
          print nl2br("Error trying to connect to the ftp server:\n- " . $ex-&gt;getMessage() . "\n");
      }
  </code></pre>
  
  <ul>
  <li>So; I did everything the official PHP installation manual said.</li>
  <li>I edited the corresponent php.ini configuration file and included the dynamic extension 'php_ftp.dll'.</li>
  <li>The library is the original file 'php_ftp.dll' that came with the installation.</li>
  <li>I also tried different PHP versions: PHP 7.1.6 and 7.0.22</li>
  <li>The PHP directory is on the Windows Environment PATH variable.</li>
  <li>I checked that the extensions directory ('ext') is being found by PHP because it detects when I remove another extension like 'php_pdo_mysql.dll'.</li>
  <li>Anyway also tried to put the library ('php_ftp.dll') on almost every directory I could think without success.</li>
  <li><p>I checked that the server supports it:</p>
  
  <pre><code>C:\Nydus\php7&gt;php -v
  PHP 7.1.8 (cli) (built: Aug  1 2017 20:56:53) ( ZTS MSVC14 (Visual C++ 2015) x64 )
  Copyright (c) 1997-2017 The PHP Group
  Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
  
  C:\Nydus\php7&gt;php --ri ftp
  
  ftp
  
  FTP support =&gt; enabled
  FTPS support =&gt; enabled
  </code></pre></li>
  <li><p>I checked that the extension is being loaded correctly:</p>
  
  <pre><code>C:\Nydus\php7&gt;php -m
  [PHP Modules]
  bcmath
  calendar
  Core
  ctype
  curl
  date
  dom
  filter
  ftp
  gd
  hash
  iconv
  json
  libxml
  mbstring
  mcrypt
  mysqlnd
  pcre
  PDO
  pdo_mysql
  Phar
  readline
  Reflection
  session
  SimpleXML
  SPL
  standard
  tokenizer
  wddx
  xml
  xmlreader
  xmlwriter
  zip
  zlib
  
  [Zend Modules]
  </code></pre></li>
  <li>Yes, I restarted the Apache service every time before checking it.</li>
  <li><p>I checked there is no bug about it in current PHP 7 distributions.
  <a href="https://bugs.php.net/index.php" rel="nofollow noreferrer">https://bugs.php.net/index.php</a></p></li>
  <li><p><strong>I even ran the function successfully from the PHP executable!</strong> and got the connection from the FTP Server:</p>
  
  <pre><code>C:\Nydus\php7&gt;php -r ftp_connect('myhostname');
  </code></pre></li>
  </ul>
  
  <p><a href="https://i.stack.imgur.com/uDACL.png" rel="nofollow noreferrer">image showing ftp connection from filezilla server</a></p>
  
  <hr>
  
  <p><strong>So I have no clue why the function is not being recognized when I use it throught my website</strong>, when I catch the error using try-catch, it gives me this error message: <strong>"Call to undefined function ftp_connect()"</strong></p>
  
  <p><strong>I would DEEPLY apreciate every bit of help you could throw on it</strong>. This is the third day I do an extensive search of information but I am still stuck with this so I'm starting to get cremated.</p>
  
  <p>If any of you need more information I will gladly cooperate.</p>
  
  <p>Thank you for reading and for your time.</p>
  
  <p>EDIT: Here is the error_log output when I try to use the ftp_function():</p>
  
  <pre><code>    [09-Aug-2017 19:05:37 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\Nydus\php7\ext\php_curl.dll' - No se puede encontrar el m�dulo especificado.
       in Unknown on line 0
      [09-Aug-2017 19:05:37 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\Nydus\php7\ext\php_ftp.dll' - No se puede encontrar el m�dulo especificado.
       in Unknown on line 0
      [09-Aug-2017 19:05:37 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\Nydus\php7\ext\php_curl.dll' - No se puede encontrar el m�dulo especificado.
       in Unknown on line 0
      [09-Aug-2017 19:05:37 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\Nydus\php7\ext\php_ftp.dll' - No se puede encontrar el m�dulo especificado.
       in Unknown on line 0
      [09-Aug-2017 19:05:59 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function ftp_connect() in C:\Nydus\Apache24\htdocs\conn_ftp.php:12
      Stack trace:
      #0 C:\Nydus\Apache24\htdocs\profile.php(6): include_once()
      #1 {main}
        thrown in C:\Nydus\Apache24\htdocs\conn_ftp.php on line 12
  </code></pre>
  
  <p>EDIT2: I'm almost absolutely sure that PHP is for some reason <em>inherent to the extension or to php itself</em> unable to load php_curl and php_ftp, because <strong>I gradually added the extensions I'm using and finds every other except those two</strong>.</p>
  
  <p>Well, I don't see what more could I test, so I will do the same project in a separate CentOs system installed in a partition, anyway if anyone knows what's happening here, please let me know.</p>
  
  <p>EDIT3: Formated the entire system and redone everything, now it works.</p>
  
  <p>The worst thing is that I will not know what was happening, but I had to do it because I've a dead line to meet.</p>
  
  <p><em>So maybe this post should be closed. Thanks for reading.</em></p>