function add_index_php($structure, $table, $index) {

        $result = '';
        // Validate if we can do it
        if (!$table = $structure->getTable($table)) {
            return false;
        }
        if (!$index = $table->getIndex($index)) {
            return false;
        }
        if ($table->getAllErrors()) {
            return false;
        }

        // Add the standard PHP header
        $result .= XMLDB_PHP_HEADER;

        // Add contents
        $result .= XMLDB_LINEFEED;
        $result .= '        // Define index ' . $index->getName() . ' ('. ($index->getUnique() ? 'unique' : 'not unique') . ') to be added to ' . $table->getName() . '.' . XMLDB_LINEFEED;
        $result .= '        $table = new xmldb_table(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED;
        $result .= '        $index = new xmldb_index(' . "'" . $index->getName() . "', " . $index->getPHP(true) . ');' . XMLDB_LINEFEED;

        // Launch the proper DDL
        $result .= XMLDB_LINEFEED;
        $result .= '        // Conditionally launch add index ' . $index->getName() . '.' . XMLDB_LINEFEED;
        $result .= '        if (!$dbman->index_exists($table, $index)) {' . XMLDB_LINEFEED;
        $result .= '            $dbman->add_index($table, $index);' . XMLDB_LINEFEED;
        $result .= '        }' . XMLDB_LINEFEED;

        // Add the proper upgrade_xxxx_savepoint call
        $result .= $this->upgrade_savepoint_php ($structure);

        // Add standard PHP footer
        $result .= XMLDB_PHP_FOOTER;

        return $result;
    }