Dear colleagues, I am currently working on a project that sends fiscal coupons, in it I came to a function that generates the nfe key, in it I get the following data:
- City code
- Year and month of issue
- Company Cnpj
- Note template (65 in case)
- Series
- Number of the note (9 positions)
- Emission type
- 8-note note number
Function code:
public function GeraChaveNFe($CodCidade , $AnoMesEmissao, $CnpjEmpresa , $Modelo , $Serie, $NumeroNF, $TipoEmissao){
$NF8 = "";
$NF9 = "";
$Chave = "";
$Digito = "";
$tam = strlen($NumeroNF);
if($tam > 0){
$NF9 = str_pad($NumeroNF, 9 - $tam, "0", STR_PAD_LEFT);
$NF8 = str_pad($NumeroNF, 8 - $tam, "0", STR_PAD_LEFT);
}else{
$NF9 = $this->right($NumeroNF, 9);
$NF8 = $this->right($NumeroNF, 8);
}
$Chave = $CodCidade . $AnoMesEmissao . $CnpjEmpresa . $Modelo . $Serie . $NF9 . $TipoEmissao . $NF8;
$Digito = $this->DigitoMod11($Chave);
return $Chave . $Digito;
}
My question is in the following function:
function right($str, $length) {
return substr($str, -$length);
}
The function Right does the same as String.Right
VB and C # , when searching I did not find the same function in php ... then I used the substr.
The question is, is the substr really the equivalent of right or is there a function that can override this method?