Search code examples
phpundefined

How to defined a variable on PHP?


//*note: problem solved// I'm using uptheme option panel for typography. I'm new in PHP and I'm getting this error:

NOTICE: wp-content/themes/XXXX/admin/library/engines/typography-engine.php:74 - Undefined index:

Line 74 contain this code:

$stylesheet = $up_fonts[$font]['style'];

I've read answers to similar questions but I've been unable to find a solution for my error. Please help. Thank you for taking your time to answer.


Solution

  • Clearly from the error can be read that the current index you are using for the array doesn't exist.

    $up_fonts[$font]['style'] is not set.

    You haven't defined your array enough. Check if the value exist with

    if (isset($up_fonts[$font]['style'])):
      $stylesheet = $up_fonts[$font]['style'];
    endif;