• Resolved choazie

    (@choazie)


    Note: not a PHP version issue, my version is 5.3.29.

    I have the following code in my template file and I’m getting a syntax error:

    <?php if(is_mobile()) {
    <div class="mobileoverlay">
    <div class="fullwidth">
    <div class="mobilecontainer">
    mobile content
    </div><!-- /.mobilecontainer -->
    </div><!-- /.fullwidth -->
    </div><!-- /.mobileoverlay -->
    }; ?>

    Am I missing something?

    Thanks in advance for answering my dumb questions 🙂

    https://wordpress.org/plugins/php-browser-detection/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Mindshare Labs, Inc.

    (@mindshare)

    That’s not valid PHP code…. you want something like this:

    <?php if(is_mobile()) : ?>
    	<div class="mobileoverlay">
    		<div class="fullwidth">
    			<div class="mobilecontainer">
    				mobile content
    			</div>
    			<!-- /.mobilecontainer -->
    		</div>
    		<!-- /.fullwidth -->
    	</div><!-- /.mobileoverlay -->
    <?php endif; ?>
    Thread Starter choazie

    (@choazie)

    Oh sorry! From the examples given, for a PHP ignoramus like me it seemed <?php if(is_mobile()) { your code }; ?> was the verbatim syntax, so I took it as my code was supposed to go where it says “your code”. Perhaps the below example would be even clearer for nitwits like me, might save you future grief?

    <?php if(is_mobile()) : ?>
         your code
    <?php endif; ?>

    Thanks again so much for getting back to me, you’re a star. The world would be a better place if only PHP pros used WordPress plugins but alas not! 😉

    Thread Starter choazie

    (@choazie)

    Now I’m getting:

    Fatal error: Allowed memory size of 41943040 bytes exhausted (tried to allocate 19922944 bytes) in wp-2015/wp-content/plugins/php-browser-detection/cache/cache.php on line 65540

    http://constantartists.com/wp-2015/jobs

    Plugin Author Mindshare Labs, Inc.

    (@mindshare)

    Yeah that’s an issue with this plugin. It doesn’t play well with most cheap shared hosting packages. You only have 40mb for PHP, this plugin really requires at least 128mb to work well. The problem is that their are so many browsers and devices (over 10,000) in the array that it takes a lot of memory to parse and store.

    Plugin Author Mindshare Labs, Inc.

    (@mindshare)

    If you can upgrade your hosting to 128mb or better still 256mb it should work, but I can’t promise anything.

    Thread Starter choazie

    (@choazie)

    Thanks, will talk to the host.

    Plugin Author Mindshare Labs, Inc.

    (@mindshare)

    “Normal” who can say?

    If you want a plugin to do what this one does, it takes more memory.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Parse error: syntax error, unexpected '’ is closed to new replies.