Jump to content

I copy a script, change a word and it fails. Why?


Rigsby

Recommended Posts

I am so frustrated. I am a php novice and have been stuck inside this lovely little world all day; it's like my first day of school :)

 

Can someone please explain to me why some of the php scripts that I copy & paste from websites work, but then don't work if I change one single and lonesome word. For example, the below script worked fine...

 

 

<?php

#adding Menu Item to primaryNavbar

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar)

{

$primaryNavbar->addChild('Menu Name')

->setUri('https://www.example.com/')

->setOrder(70);

});

 

 

...but when I changed 'Menu Name' to something else, I got a white page. This has happened so many times today with, I don't know, about a hundred or more scripts. Is it related to what version php my provider is running or something more technical?

 

Thanks in advance for any advice and help :)

Link to comment
Share on other sites

because hooks are very fragile and if you get the slightest thing wrong, you'll get a blank screen... and if you get them very wrong, you can get a blank screen in both client and admin areas!

 

use the "Display errors" option I mentioned previously.

Link to comment
Share on other sites

Good advice from Brian. That should tell you what's failing, usually.

Guessing what the problem might be; if the syntax is exactly the same (name enclosed by single quotes) I'd consider the editor being used, followed by upload method may be behind this.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated