I have a problem with php. I was trying to change my homepage on theme twentyeleven. Its a beginning of my functions.php script. Syntax error, unexpected T_IF is on line 1. Could you help me to find out whats the problem?

<?php/** * Twenty Eleven functions and definitions * * Sets up the theme and provides some helper 

functions. Some helper functions * are used in the theme as custom template tags. Others are attached to 

action and * filter hooks in WordPress to change core functionality. * * The first function, 

twentyeleven_setup(), sets up the theme by registering support * for various features in WordPress, such 

as post thumbnails, navigation menus, and the like. * * When using a child theme (see 

http://codex.wordpress.org/Theme_Development and * http://codex.wordpress.org/Child_Themes), you can 

override certain functions * (those wrapped in a function_exists() call) by defining them first in your 

child theme's * functions.php file. The child theme's functions.php file is included before the parent * 

theme's file, so the child theme functions would be used. * * Functions that are not pluggable (not 

wrapped in function_exists()) are instead attached * to a filter or action hook. The hook can be removed 

Recommended Answers

All 9 Replies


Just bring down the comment tags. One more thing multi-line comment in php should be like this


/* beginning of long comments from the author

*close the comment tag below


The script looks like this. I saved changes and something happened with it. Why aren't there empty lines? How can I fix it? Thank you for your reply


What is your php/text editor? try using notepad++ or php designer 2007 personal edition. Both are free at cnet.

To fix it you really need to read line by line and try sorting it really well and add carriage return where it is needed.

I use notepad. thank you for attention

It's not notepad what @veedeoo is mentioning. Notepad is not good IDE to write the code or any programming language. You should use another IDE which has more features and good supporting for multiple programming languages such as PHP, HTML, ASP or Java. Here are some good tools you should try. Notepad++ ( http://notepad-plus-plus.org/download/v6.1.3.html ), SublimeText2 ( http://www.sublimetext.com/2 ), AptanaStudio3 ( http://www.aptana.com/products/studio3/download ). I prefer to use Notepad++ and SublimeText2 rather than AptanaStudio3. These two IDEs are comfortable with small projects like PHP, HTML, Javascript and any web development.

I already downloaded notepad++ and phpedesigner 2007. Thank you for your reply

Well. No one listen to the forum rules. You might mark as Solved when your problem was solved.

The problem wasn't solved by downloading notepad++. Anyway thank you for reminding me

Same kind of problem here :( I was trying to solve a problem with Ajax Calender by pasting this code at the buttom in functions.php of my theme Twenty Eleven:

if ( get_magic_quotes_gpc() ) {
    $_POST      = array_map( 'stripslashes_deep', $_POST );
    $_GET       = array_map( 'stripslashes_deep', $_GET );
    $_COOKIE    = array_map( 'stripslashes_deep', $_COOKIE );
    $_REQUEST   = array_map( 'stripslashes_deep', $_REQUEST );


When it didn't work I wanted to delete this part again and save, but I got the following message: "Parse error: syntax error, unexpected '<' in /homez.705/jrkdeste/www/wp-content/themes/twentyeleven/functions.php on line 673"

This is what I see in the last part of the code:

add_filter( 'body_class', 'twentyeleven_body_classes' );

 * Retrieves the IDs for images in a gallery.
 * @uses get_post_galleries() first, if available. Falls back to shortcode parsing,
 * then as last option uses a get_posts() call.
 * @since Twenty Eleven 1.6.
 * @return array List of image IDs from the post gallery.
function twentyeleven_get_gallery_images() {
    $images = array();

    if ( function_exists( 'get_post_galleries' ) ) {
        $galleries = get_post_galleries( get_the_ID(), false );
        if ( isset( $galleries[0]['ids'] ) )
            $images = explode( ',', $galleries[0]['ids'] );
    } else {
        $pattern = get_shortcode_regex();
        preg_match( "/$pattern/s", get_the_content(), $match );
        $atts = shortcode_parse_atts( $match[3] );
        if ( isset( $atts['ids'] ) )
            $images = explode( ',', $atts['ids'] );

    if ( ! $images ) {
        $images = get_posts( array(
            'fields'         => 'ids',
            'numberposts'    => 999,
            'order'          => 'ASC',
            'orderby'        => 'menu_order',
            'post_mime_type' => 'image',
            'post_parent'    => get_the_ID(),
            'post_type'      => 'attachment',
        ) );

    return $images;

Does anyone know what I can do to fix this? I don't no anything about codes :s


Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.