Help with this function

writing echo

what should it print? when i pasted it on netbean i gave me error what am i doing wrong ?

When posting code on the forum, either place it between bbcode [ code ] [ /code ] tags (without the spaces) or between back-quotes/back-ticks (assuming the code doesn’t contain any.)

Also, if you are getting an error, you will need to post it since we aren’t sitting there with you and can’t see the screen on your computer.

three back ticks are all that really work with this software. I have been formatting code as I see it!

The echo is attempting to print the table structure…

I’ve been using bbode code tags for the code I have been posting.

you’re right!

it gives me this error:
Fatal error : Uncaught Error: Call to undefined function telefono() in C:\xampp\htdocs\PhpProject1\index.php:37 Stack trace: #0 {main} thrown in C:\xampp\htdocs\PhpProject1\index.php on line 37

because when i was trying to do it , i separated the html code(the table) and the php code

While separation is ideal, sometimes it is harder because of how the code is structured.

For instance, rather than having this happen to generate the page, you have an ajax call happen when the page is loading.

what’s the error in your opinion in the project? thanks

You are trying to use a function before it is defined. Meaning, the function doesn’t exist yet, but you are still trying to call it.

i created the function “telefono” , in the first exercise i had to create this function to make the phone number with the point example: make 3335276282 ===> 333.5276282

function telefono ($telefono=null){
$prefisso= substr($telefono , 0 , 3);
$restantenum=substr($telefono , 3);
return $prefisso . “.” . $restantenum;
}

now it gives me error

Notice : Undefined offset: 7 in C:\xampp\htdocs\PhpProject1\index.php on line 53

Notice : Undefined offset: 8 in C:\xampp\htdocs\PhpProject1\index.php on line 53

Notice : Undefined offset: 9 in C:\xampp\htdocs\PhpProject1\index.php on line 53

Notice : Undefined offset: 10 in C:\xampp\htdocs\PhpProject1\index.php on line 53

That isn’t your issue,

Your current list of errors are because you changed the meaning of the $heading array, which has since been deleted from the replies, and because of this -

Because the code is using numerical indexes and you added ‘formatting’ elements to the $heading definition, the code is trying to reference elements in the data that don’t exist.

at the beginning i wrote it so:

`nl="<br/>";
static $dentisti;
//$dentisti=array("nome", "id", "ragione_sociale", "indirizzo", "telefono" );
$dentisti=array();

$cellulare_formatted="";
$dentista1=array("Luca", "1234", "Luca Rossi", "viale monza 146", "3335276282");
$dentista2=array("Mariella", "6353", "Mariella Verdi", "via caviglia 3", "3663638331");
$dentista3=array("Ludmilla", "8372", "Ludmilla Pini", "viale lunigiana 5", "3278423782");
$dentista4=array("Jacopo", "3490", "Jacopo Kadiri", "via fermi 67", "3459095479");
$dentista5=array("Giovanni", "5739", "Giovanni Abate", "via torino 4", "3844389380");

$a= "nome";
$b="id";
$c="ragione_sociale";
$d="indirizzo";
$e="telefono";
$f="edit";




function telefono ($telefono=null){
    $prefisso= substr($telefono , 0 , 3);
    $restantenum=substr($telefono , 3);
    return $prefisso . "." . $restantenum;
}

<TABLE> 

<tr>
    <td><?= $a; ?></td><td> <?= $b; ?></td><td> <?= $c; ?></td><td><?= $d; ?></td><td><?= $e; ?></td><td><?= $f; ?></td> 
</tr>
<?php


 array_push($dentisti, $dentista1, $dentista2, $dentista3, $dentista4, $dentista5);

//     var_dump($dentisti); 
     echo($nl);
foreach($dentisti as $dentista){
    $cellulare_formatted=telefono($dentista[4]);
   //  var_dump($dentista); 
   ?>
<tr><td> <?= $dentista[0]; ?> </td><td> <?= $dentista[1]; ?> </td><td> <?= $dentista[2]; ?> </td> <td> <?= $dentista[3]; ?> </td><td> <?= $cellulare_formatted; ?> </td><td><a href="<?=getlink($dentista[1])?>"> info </a></td> 
</tr>
   
<?php   
echo (" Totale Medici: " . count($dentista1)); 
 ?>

i don’t know how to post it right…what do you suggest?

anyway what do you think?

what do you think of my code?

I think those should be objects. It will make the code cleaner and easier to understand. And I think the details should come from a database.

Sponsor our Newsletter | Privacy Policy | Terms of Service