PHP Function parameters - problem with var not being set

Posted by Marty on Stack Overflow See other posts from Stack Overflow or by Marty
Published on 2010-03-22T20:28:49Z Indexed on 2010/03/22 20:31 UTC
Read the original article Hit count: 214

Filed under:
|
|

So I am obviously not a very good programmer. I have written this small function:

function dispAdjuggler($atts) {
extract(shortcode_atts(array(
    'slot' => ''
), $atts)); 

$adspot = '';
$adtype = '';

// Get blog # we're on
global $blog_id;
switch ($blog_id) {
    case 1:
        // root blog HOME page
        if (is_home()) {
            switch ($slot) {
                case 'top_leaderboard':
                    $adspot = '855525';
                    $adtype = '608934';
                break;
                case 'right_halfpage':
                    $adspot = '855216';
                    $adtype = '855220';
                break;
                case 'right_med-rectangle':
                    $adspot = '858222';
                    $adtype = '613526';
                break;
                default:
                    throw new Exception("Ad slot is not defined");
                break;
            }

When I reference the function on a page like so:

<?php dispAdjuggler("top_leaderboard"); ?>

The switch is throwing the default exception. What am I doing wrong here?

Thanks!!

© Stack Overflow or respective owner

Related posts about parameters

Related posts about function