• Resolved et3ishak

    (@et3ishak)


    Parse error: syntax error, unexpected ‘<‘ on line 17

    Hello, I am learning to write the plugins for WordPress. I get the above error when attempting to activate my plugin in wordpress.

    Am I not able to use html?

    when I remove the html, I get no parse error when activating.

    The following is my code:

    <?php
    /**
     * Plugin Name: somePlugin
     * Plugin URI: http://www.syntaxbytes.com
     * Description: This is a description
     * Version: 1.0
     * Author: Paul Ishak
     * Author URI: http://www.syntaxbytes.com
     * License: GPL2
     */
     # Generated with WordPressPluginDesigner v0.1
        add_action('admin_menu', 'somePlugin_admin_actions');
        function somePlugin_admin_actions(){
            add_options_page('Some Plugin Settings', 'somePlugin', 'manage_options', __FILE__, 'somePlugin_admin');
        }
        function somePlugin_admin() {
        <img src="http://www.syntaxbytes.com/pluginimages/feature3.png"/>
        }
    ?>

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter et3ishak

    (@et3ishak)

    Ok, I just echo’d each line, that seems to work ok.

    <?php
    /**
     * Plugin Name: somePlugin
     * Plugin URI: http://www.syntaxbytes.com
     * Version: 1.0
     * Author: Paul Ishak
     * Author URI: http://www.syntaxbytes.com
     * License: GPL2
     */
     # Generated with WordPressPluginDesigner v0.1
        add_action('admin_menu', 'somePlugin_admin_actions');
        function somePlugin_admin_actions(){
            add_options_page('Hello World Settings', 'somePlugin', 'manage_options', __FILE__, 'somePlugin_admin');
        }
        function somePlugin_admin() {
            echo "<html>";
            echo "	<div class=\"wrap\">";
            echo "        <h4>";
            echo "		    Some Plugin's Settings";
            echo "		</h4>";
            echo "		<img src=\"http://www.syntaxbytes.com/pluginimages/feature3.png\"/>";
            echo "    </div>";
            echo "</html>";
        }
    ?>

    Moderator bcworkz

    (@bcworkz)

    Hey et3ishak,
    Even though you found a solution, you should know the problem with your original code is you never closed out the PHP block in order to output HTML. You would need to do this on the one HTML line:
    ?><img src="http://www.syntaxbytes.com/pluginimages/feature3.png"/><?php

    That said, certain admin area callbacks (not sure which) do not seem to allow HTML this way, you must echo out any content. Echoing will always work, so you found a good solution.

    Thread Starter et3ishak

    (@et3ishak)

    It is strange, I actually did eventually find an example that shows the way you suggest, but when I did it that way, for some reason the image was placed in the top left corner of the webpage, regardless of permissions/access, and offset the entire page. Then I read more about the wrap class. thanks for your help.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Parse Error’ is closed to new replies.