0

i am trying to pass the value of $page="somepage"; throught a function suppose

function example($page)

        {
                    echo $page;
   ?>
   <input type="radio" name="smoke" value="Y"> Yes
   <input type="radio" class="ml_10" name="smoke" value="N"> No
   <input type="radio" class="ml_10" name="smoke" value="O"> Occasionally
   <?php
        }

example ($page);

When i try to echo the page it should come as somepage but instead its coming 1. but if i manually write page while calling functions it prints right for eg example ("somepage").

0

2 Answers 2

2

Your $page variable contains number 1 before calling example() function
So, you have to make it contain "somepage" value instead.

OR

your example() function contains some code that converts "somepage" to 1.

most likely its something like

$page = include $page;

line which you omit from your question for some unknown reason

Either way question being too localized and thus not suitable for Stack Overflow

Sign up to request clarification or add additional context in comments.

Comments

0

As long as you declare $page before calling the function, what you're trying to do will work.

$page = "somepage";

example($page);


function example($page)

{
    echo $page;
    ?>
    <input type="radio" name="smoke" value="Y"> Yes
    <input type="radio" class="ml_10" name="smoke" value="N"> No
    <input type="radio" class="ml_10" name="smoke" value="O"> Occasionally
    <?php
}

4 Comments

i am declaring the $page at top of the page and calling the function at bottom
@user1001176 That is fine, but make sure the value of $page is staying consistent through the script. Are you assigning it to a boolean value at any point?
no i am not i really dont know why is this happening i mean my code is right i know that all my functions are stopped i was passing value of page in all of them . any quick fix to this ?
@user1001176 Upload the entire code, that's the only way I'd be able to find your issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.