Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Php Help

  • 03-08-2010 10:35AM
    #1
    Registered Users, Registered Users 2 Posts: 14,007 ✭✭✭✭


    Would someone be so kind as to tell me how to remove the paragraph and class tags from this code in a way that the code will still work. It's from a joomla module but the paragraph tags break the xhtml compliance. I tried to do it but withou success. I'm no coder.
    return $news_text = '<p class="fanews_text '.$class.'">'.$news_text.'</p>';
    }


Comments

  • Registered Users, Registered Users 2 Posts: 9,579 ✭✭✭Webmonkey


    Just

    [php]return $news_text;[/php]

    But what exactly is the compliance error. Maybe it would be better fix that than just removing the paragraph?


  • Registered Users, Registered Users 2 Posts: 14,007 ✭✭✭✭The Muppet


    Webmonkey wrote: »
    Just

    [php]return $news_text;[/php]

    But what exactly is the compliance error. Maybe it would be better fix that than just removing the paragraph?

    Thanks for that. It a news module which uses tiny mce to input the text. This automatically puts the text in paragraph tags. This leaves me with paragraph tags within empty paragraph tags which fails xhtml validation.

    That's my take on it anyway, I understand enough to find my way around but as I said I'm no coder . Thank's a million for your help I appreciate it.


    EDIT just implememnted that and it worked a treat

    Thanks again


  • Registered Users, Registered Users 2 Posts: 339 ✭✭spoonface


    The Muppet wrote: »
    Would someone be so kind as to tell me how to remove the paragraph and class tags from this code in a way that the code will still work. It's from a joomla module but the paragraph tags break the xhtml compliance. I tried to do it but withou success. I'm no coder.

    The problem is that you tried to return the result (probably 0) of the operation of assigning a value to a variable. Whereas what you really wanted to do was assign the variable and then return the variable value. The compliance issue is about how anally the PHP installation will check for errors users make and reject them. It's decided you've made a mistake here and it's correct so it flags it as an error and lets you work it out, fix it and run it again. So to be clear, it's not about the paragraph tags, it's about how you did 'return x=y' when you should do 'x=y; return x'.


  • Registered Users, Registered Users 2 Posts: 14,007 ✭✭✭✭The Muppet


    spoonface wrote: »
    The problem is that you tried to return the result (probably 0) of the operation of assigning a value to a variable. Whereas what you really wanted to do was assign the variable and then return the variable value. The compliance issue is about how anally the PHP installation will check for errors users make and reject them. It's decided you've made a mistake here and it's correct so it flags it as an error and lets you work it out, fix it and run it again. So to be clear, it's not about the paragraph tags, it's about how you did 'return x=y' when you should do 'x=y; return x'.

    I think I understand that,I still wouldn't know enough about coding to fix it on my own, I might next time now that it's been explained.

    Removing the class style worked fine this time, I can style it using the site stylesheet. It's on a personal hobby site I like to tinker around with.


Advertisement