Well, I have a PHP variable an index.php page. And when I click, I load another part of the page inside a div with javascript. When loading the page, the index variable is not recognized inside the div page (which is also .php).
<?php
$variavel = 1234;
?>
<script>
function carregar(pagina){
$("#conteudo").load(pagina);
}
</script>
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link active" onclick="carregar('includes/graficos/pesoaluno.php')" href="#">Registro de peso</a>
</li>
</ul>
<div id="conteudo"></div>