-3

I try many solution but it does help.i try even to switch on short_tags_on but no solution.

I am getting this error:

Parse error: syntax error, unexpected end of file in C:\xampp\htdocs\photo_gallery\includes\functions.php on line 76

Here is my code, what is wrong?

<?php

function strip_zeros_from_date( $marked_string="" ) {
  // first remove the marked zeros
  $no_zeros = str_replace('*0', '', $marked_string);
  // then remove any remaining marks
  $cleaned_string = str_replace('*', '', $no_zeros);
  return $cleaned_string;
}

function redirect_to( $location = NULL ) {
  if ($location != NULL) {
    header("Location: {$location}");
    exit;
  }
}

function output_message($message="") {
  if (!empty($message)) { 
    return "<p class=\"message\">{$message}</p>";
  } else {
    return "";
  }
}

function __autoload($class_name) {
    $class_name = strtolower($class_name);
  $path = LIB_PATH.DS."{$class_name}.php";
  if(file_exists($path)) {
    require_once($path);
  } else {
        die("The file {$class_name}.php could not be found.");
    }
}


function include_layout( $names, $args ){
  // allow for single file names
  if ( !is_array( $names ) ) { 
    $names = array( $names ); 
  }

  $found = false;
  foreach ( $names as $name ) {
    $file = siteroot.'/public/layouts/'.$name.'.php';

    if ( file_exists( $file ) ) {
      $found = $file;
      break;
    }
  }

  if ( ! $found ) {
    return '';
  }

function log_action($action, $message="") {
    $logfile = SITE_ROOT.DS.'logs'.DS.'log.txt';
    $new = file_exists($logfile) ? false : true;
  if($handle = fopen($logfile, 'a')) { // append
    $timestamp = strftime("%Y-%m-%d %H:%M:%S", time());
        $content = "{$timestamp} | {$action}: {$message}\n";
    fwrite($handle, $content);
    fclose($handle);
    if($new) { chmod($logfile, 0755); }
  } else {
    echo "Could not open log file for writing.";
  }
}

function datetime_to_text($datetime="") {
  $unixdatetime = strtotime($datetime);
  return strftime("%B %d, %Y at %I:%M %p", $unixdatetime);
 }

 ?>

I am using xampp on Windows 7. I have been trying to find a solution but I dont know what wrong. Since I added the function method of including the header.php and footer.php it start giving me that error. Here is the method that I add:

function include_layout( $names, $args ){
  // allow for single file names
  if ( !is_array( $names ) ) { 
    $names = array( $names ); 
  }

  $found = false;
  foreach ( $names as $name ) {
    $file = siteroot.'/public/layouts/'.$name.'.php';

    if ( file_exists( $file ) ) {
      $found = $file;
      break;
    }
  }

  if ( ! $found ) {
    return '';
  }
halfer
  • 19,824
  • 17
  • 99
  • 186
tina
  • 1
  • 1
  • If you install an IDE (e.g. NetBeans for PHP) then your edit window will show you syntax errors even without you having to run the code. – halfer Aug 20 '17 at 11:32

1 Answers1

1

You're not closing the include_layout function, it's missing a final }.

function include_layout( $names, $args ){
  // allow for single file names
  if ( !is_array( $names ) ) { 
    $names = array( $names ); 
  }

  $found = false;
  foreach ( $names as $name ) {
    $file = siteroot.'/public/layouts/'.$name.'.php';

    if ( file_exists( $file ) ) {
      $found = $file;
      break;
    }
  }

  if ( ! $found ) {
    return '';
  }
} // << missing from your code
Lawrence Cherone
  • 46,049
  • 7
  • 62
  • 106