How to resolve "Parse error: syntax error" in PHP? -
this question has answer here:
- php parse/syntax errors; , how solve them? 11 answers
i try many solution help.i try switch on short_tags_on no solution.
i getting error:
parse error: syntax error, unexpected end of file in c:\xampp\htdocs\photo_gallery\includes\functions.php on line 76
here code, wrong?
<?php function strip_zeros_from_date( $marked_string="" ) { // first remove marked zeros $no_zeros = str_replace('*0', '', $marked_string); // remove 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 not found."); } } function include_layout( $names, $args ){ // allow single file names if ( !is_array( $names ) ) { $names = array( $names ); } $found = false; foreach ( $names $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 writing."; } } function datetime_to_text($datetime="") { $unixdatetime = strtotime($datetime); return strftime("%b %d, %y @ %i:%m %p", $unixdatetime); } ?>
i using xampp on windows 7. have been trying find solution dont know wrong. since added function method of including header.php
, footer.php
start giving me error. here method add:
function include_layout( $names, $args ){ // allow single file names if ( !is_array( $names ) ) { $names = array( $names ); } $found = false; foreach ( $names $name ) { $file = siteroot.'/public/layouts/'.$name.'.php'; if ( file_exists( $file ) ) { $found = $file; break; } } if ( ! $found ) { return ''; }
you're not closing include_layout function, it's missing final }
.
function include_layout( $names, $args ){ // allow single file names if ( !is_array( $names ) ) { $names = array( $names ); } $found = false; foreach ( $names $name ) { $file = siteroot.'/public/layouts/'.$name.'.php'; if ( file_exists( $file ) ) { $found = $file; break; } } if ( ! $found ) { return ''; } } // << missing code
Comments
Post a Comment