PHP code example of phpcfdi / rfc

1. Go to this page and download the library: Download phpcfdi/rfc library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

phpcfdi / rfc example snippets


use PhpCfdi\Rfc\Rfc;
// suponiendo que llega un formulario con rfc => COSC8001137NA
$rfc = Rfc::parse($_POST['rfc']);
echo $rfc->getRfc(); // COSC8001137NA
echo $rfc; // COSC8001137NA
echo json_encode(['data' => $rfc]); // {"data": "COSC8001137NA"}
var_dump($rfc->isFisica()); // bool(true)
var_dump($rfc->isMoral()); // bool(false)
var_dump($rfc->isGeneric()); // bool(false)
var_dump($rfc->isForeign()); // bool(false)