the poo instructions do not work with apache2


I had installed xampp and my code of a menu worked correctly using Object Oriented Programming, I had to reinstall my system but now install apache2 php5 and mysql. The codes were not modified, and they do not work for me.

<nav class="navbar navbar-inverse">
    class urls{
      private $archivo_actual; 
      public function urls($archivo){
      public function acti($boton){
        if ($boton==$this->archivo_actual){
          echo ('class="active"');
          echo (' ');
      public function url( $sitio){ //para usar con las otras paginas.
          echo 'href="pages/'.$sitio.'"';
          echo 'href="'.$sitio.'"';
      public function urli(){ //para usar desde la principañ
        if ($this->archivo_actual=="index.php") {
          echo 'href=index.php';
          echo 'href="../index.php"';
    $ur = new urls(basename($_SERVER["PHP_SELF"])); //obtenemos la url y la mandamos
  <div class="container-fluid">
    <div class="navbar-header">
    <button type="button" class="navbar-toggle" data-toggle="collapse"
      <span class="sr-only">Desplegar navegación</span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
    <a class="navbar-brand" href="">SmanTech</a>
  <div class="collapse navbar-collapse navbar-ex1-collapse">
    <ul class="nav navbar-nav">

    <li <? $ur->acti("index.php"); ?>>
      <a <? $ur->urli("index.php"); ?>> Home</a>
      <li <? $ur->acti("equi.php"); ?>>
        <a <? $ur->url("equi.php"); ?> > Equipos </a>
      <li <? $ur->acti("dep.php"); ?>>
        <a <? $ur->url("dep.php"); ?>> Dependencias </a>
      <li <? $ur->acti("tec.php"); ?>>
        <a <? $ur->url("tec.php"); ?>> Tecnicos </a>
      <li <? $ur->acti("solc.php"); ?>>
        <a <? $ur->url("solc.php"); ?>> Solicitudes </a>
      </li >
      <li <? $ur->acti("hist.php"); ?>>
        <a <? $ur->url("hist.php"); ?>> Historiales </a>
    <ul class="nav navbar-nav navbar-right">
      <!-- <li><a href="#">Enlace #3</a></li> -->
      <li class="dropdown">
        <a href="#" class="dropdown-toggle" data-toggle="dropdown">
          <? echo $_SESSION['user']; ?> <b class="caret"></b>
        <ul class="dropdown-menu">
          <li><a href="#">Configuracion</a></li>
          <li><a href="#">Acción #2</a></li>
          <li><a href="#">Acción #3</a></li>
          <li class="divider"></li>
          <li><a <? $ur->url("logout.php"); ?>>Cerrar Sesión</a></li>

This is what happens when I use this code

asked by Johnny Pachecp 05.10.2016 в 05:07

1 answer


Using my magic powers, I can see that the php interpreter is not running, and therefore Apache is serving the file as it is stored on the disk, without interpreting the source code of the script. You can confirm this by viewing the source code of the page that has been served to the browser.

This may be happening basically for 2 reasons:

Does not load the php module

Apache is not loading the php interpreter module. To solve it, edit the file httpd.conf , according to the documentation :

LoadModule php5_module "c:/php/php5apache2.dll"
AddHandler application/x-httpd-php .php

# Configurar la ruta de php.ini
PHPIniDir "C:/php"

Note: Remember to replace the current PHP path to the C: / php / in the previous examples. Be careful to use either php5apache2.dll or php5apache2_2.dll in the LoadModule directive and verify that the reference file is located in the file path indicated in this directive.

It can also happen that if you load the module but

The interpreter for your file is not running

Apache generally uses one or more rules on the file extension to decide that it is processed by the php interpreter and not.

This is also set to httpd.conf . Search or add rules such as:

#Los archivos con extensión .php se procesarán con php
<FilesMatch \.php$>
      SetHandler application/x-httpd-php
answered by 05.10.2016 в 06:15