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

  • SEARCH
  • Home
  • 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 8014117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:49:57+00:00 2026-06-04T19:49:57+00:00

PLS. I am very NEW to PHP so pls. understand. OK so here it

  • 0

PLS. I am very NEW to PHP so pls. understand.
OK so here it goes. . What I want to know first is that “Can a function and an if statement be in one code?” second for the code below, just take a look at where the NOTE is, what should i type in the if statement to make it say ” ARE THE SAME” if the values of the parameters $first and $second are the same and say ” ARE NOT THE SAME” if not.

    <?php
    function verify($first,$second)
    {
    echo $first . " and " . $second ;
    }
    echo
    verify ("1","2");

    if ($first === $second) /* **NOTE: I know this is wrong cause its not working** */
    echo " ARE THE SAME";
    else
    echo " ARE NOT THE SAME";
    ?>

I think thats about it.
Can anyone help?

  • 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-06-04T19:50:01+00:00Added an answer on June 4, 2026 at 7:50 pm

    Your basic problem is one of scope. Outside verify(), $first and $second are not defined. You could simply include the rest of your code inside the function body which would do what you want, eg

    function verify($first,$second) {
        echo $first . " and " . $second ;
    
        if ($first === $second) {
            echo " ARE THE SAME";
        } else {
            echo " ARE NOT THE SAME";
        }
    }
    
    verify("1", "2");
    

    … however functions that write to the output buffer are rarely a good idea. Instead, encapsulate the logic inside your function and leave the display to procedural code, eg

    function verify($a, $b) {
        return $a === $b;
    }
    
    $first = '1';
    $second = '2';
    echo $first, ' and ', $second;
    if (verify($first, $second)) {
        echo ' are the same';
    } else {
        echo ' are not the same';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am very confused about spring controllers, pls help me. i want to know
pls help me to understand the conception of UiView and UIViewController, i know that
i'm new to xslt pls provide the xslt that compare two node based on
I have a question that can I use AS400ConnectionPool in Spring if then pls
I know this very silly, but can anybody help me in understanding what does
I am very new to android development.... i have created an app and want
I'm trying to get a very simple Javascript function to work that will change
i want to make a simple jquery slider, i dont know jquery very well,
If its not relevant here, pls. move to correct place. I want to find
I have only a very basic knowledge of SQL, so pls do forgive if

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.