Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6830585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:38:07+00:00 2026-05-26T22:38:07+00:00

I’m trying to call a function that catches variables value on call: the function:

  • 0

I’m trying to call a function that catches variables value on call:

the function:

function check_input_data($INCLUDE_DISABLEDd_types = '', $field1 = '', $field2 = '', $field3 = '', $field4 = '', $field5 = '', $field6 = '', $field7 = '', $field8 = '')
{
    if ( !empty( $INCLUDE_DISABLEDd_types ) )
    {
        global $field1, $field2, $field3, $field4, $field5, $field6, $field7, $field8, $field_1_status, $field_2_status, $field_3_status, $field_4_status, $field_5_status, $field_6_status, $field_7_status, $field_8_status;
        if ( $INCLUDE_DISABLEDd_types == 'email_u' )
        {
            echo "It's noticed the INCLUDE_DISABLEDd var";
            if ( !empty( $field1 ) )
            {
                //I'll tell you what to do later
            }
            if ( !empty( $field2 ) )
            {
                echo $field2;
                if ( preg_match( "/[^-a-z0-9_]/i", $field2 ) )
                {
                    $field_2_status = true;
                    $ff = "good input?";
                }
                else if ( !preg_match( "/[^-a-z0-9_]/i", $field2 ) )
                {
                    $field_2_status = true;
                    $ff = "bad input?";
                }
                else
                {
                    $ff= "something is wrong with preg match";
                }
                echo $ff;
            }
        }
    }
}

Okay so as you can see, the function will look for only 3 different variables(for now). If it finds them, it will do something.

Now here is the call the the function:

check_input_data ('email_u', 'test1', 'LOOK FIELD TWO IS HERE');

Now the first var in the function call is for $included_types the second for $field1 and the third for $field2.

For some reason, the first var ($included_types) which i give a value of email_u is detected but the rest ($field1 and $field2) is not.

The reason i know the first var ($included_types) is detected is because it echo’s out “It’s noticed the included var”.

As you can see, I’ve got an if statement to check if $field2 is empty and if it’s not then i tell it to echo the var. Now it doesn’t execute any code because it thinks $field2 is empty (when its not) so i then change the if statement to do the task if it IS empty and it does it but it echos $field2 with absolutely nothing so i know its not the empty function.

It somehow thinks $field2 is empty.

I’ve also tried giving values for ALL vars:

check_input_data ('email_u', 'test1', 'LOOK FIELD TWO IS HERE', 'test', 'test', 'test', 'test', 'test', 'test');

but it still only picks up the first var, not the rest.

Have I completely mis-understood something? or is there something wrong with the code?

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:38:07+00:00Added an answer on May 26, 2026 at 10:38 pm

    Remove the global line and it should work.

    Generally it is considered bad practice to use global variables at all, You should instead pass them into the function as parameters (as it seems you have already done).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.