Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,589 members, 7,809,130 topics. Date: Friday, 26 April 2024 at 12:32 AM

Webmasters Enter Here If You Can Solve These PHP Questions... - Webmasters (2) - Nairaland

Nairaland Forum / Science/Technology / Webmasters / Webmasters Enter Here If You Can Solve These PHP Questions... (9298 Views)

Webmasters: Enter Here And Clarify Me Biko! / Webmasters: Enter Here And Clarify Me Biko! / All Nairaland Webmasters: Enter Here Now!! (2) (3) (4)

(1) (2) (3) (Reply) (Go Down)

Re: Webmasters Enter Here If You Can Solve These PHP Questions... by telim: 2:43pm On Apr 30, 2015
W
Re: Webmasters Enter Here If You Can Solve These PHP Questions... by Nobody: 2:45pm On Apr 30, 2015
This guys just paste the stuffs in a browser and got the salient answers... Kudos to y'all.
Re: Webmasters Enter Here If You Can Solve These PHP Questions... by grownaira: 2:45pm On Apr 30, 2015
Gurus in d house. I wana buid a site similar to www.thesummary.com.ng using CMS (I no sabi code at all at all).

Please what user friendly cms will do d job perfectly.

Thanks
Re: Webmasters Enter Here If You Can Solve These PHP Questions... by telim: 2:46pm On Apr 30, 2015
What is all these double colon and single colon op, hunah no go kill us for these country. All the same these are basic php code nah. I will only contribute when i see more difficult problem.
Re: Webmasters Enter Here If You Can Solve These PHP Questions... by Nobody: 2:46pm On Apr 30, 2015
I wud answer it later if nobody gets it rite.. Curently buyin fuel.
Re: Webmasters Enter Here If You Can Solve These PHP Questions... by teemy(m): 2:49pm On Apr 30, 2015
FRInteractives:
Question 1

Q: What is wrong with this query:
"SELECT *
FROM table WHERE id = $_POST
[ 'id' ]" ?

"SELECT * FROM table WHERE id = $_POST[ 'id' ]" ?
*******************************************************************
Q: What is the preferred way to write this if statement, and why?

if( 5 == $someVar ) or if( $someVar == 5 )
***********************************************************************
Q: Given this code:

function doSomething( &$arg )
{
$return = $arg;
$arg += 1;

return $return;
}
$a = 3;
$b = doSomething( $a );
...what is the value of $a and $b after the function call and why?

$b = 3 because it has the value of the of the inputed variable initial value. The $a was autoincremented after the return variable was assigned
$a = 4 as it has been autoincremented by 1. However only valid within the function ellse undefined if called outsie it.
NB. considering that &$arg is a typo

***********************************************************************
Question 4

Q: Consider these lines of codes:
//first code
$myVar = "I am Something";

$myVar .= "So Special";

echo "Do you Know $myVar";

And
//second code
$myVar = "I am Something";

$myVar .= "So Special";

echo 'Do you Know $myVar';

Now if you run these two codes in a Browser what will be the output?

The same Do you Know $myVar and not Do you Know I am SomethingSo Special
NB. There was no concatenation between string and assumed variable
Re: Webmasters Enter Here If You Can Solve These PHP Questions... by cbrass(m): 2:54pm On Apr 30, 2015
$age= 15;

($age<15) ? 'Accept': 'Reject';

Who can explain what this code will do and what's the name of this expression?


Cc jregz craigston
Re: Webmasters Enter Here If You Can Solve These PHP Questions... by codemarshal08(m): 3:13pm On Apr 30, 2015
cbrass:
$age= 15;

($age<15) ? 'Accept': 'Reject';

Who can explain what this code will do and what's the name of this expression?


Cc jregz craigston

[s] Name: Ternary Operator it is a short-hand notation for writing conditional statements[/s]
oOps, he asked for name of expression not operator's name. Expression name: Conditional Expression

($age<15) ? 'Accept': 'Reject';
the above code will return Accept if age is less than 15 Else it returns Reject

3 Likes

Re: Webmasters Enter Here If You Can Solve These PHP Questions... by Pakingzzz(m): 3:21pm On Apr 30, 2015
Well, thats nice..
Here's the first House building machine in Nigeria. It is going to be run by software.
This machine will be capable of building a house from the floor level to the building level. Check her; www.nairaland.com/2217438/sponsor-me-build-3d-house
Re: Webmasters Enter Here If You Can Solve These PHP Questions... by VoteOutPDPJona: 3:21pm On Apr 30, 2015
Gotta go back to my coding class.
Re: Webmasters Enter Here If You Can Solve These PHP Questions... by Donpizzle(m): 3:32pm On Apr 30, 2015
FRInteractives:
Question 1
Q: What is wrong with this query: "SELECT * FROM table WHERE id = $_POST [ 'id' ]" ?
IF U ASK ME NA WHO I GO ASK
Re: Webmasters Enter Here If You Can Solve These PHP Questions... by cbrass(m): 4:01pm On Apr 30, 2015
codemarshal08:


Name: Ternary Operator it is a short-hand notation for writing conditional statements
($age<15) ? 'Accept': 'Reject';
the above code will return Accept if age is less than 15 Else it returns Reject

Correct man grin
Re: Webmasters Enter Here If You Can Solve These PHP Questions... by Nobody: 4:02pm On Apr 30, 2015
FRInteractives:
Question 2

Q: What is the preferred way to write this if
statement, and why?

if( 5 == $someVar ) or
if( $someVar == 5 )

the correct way to write this statement is:

if ($SomeVar == 5)
cos somevar in a variable and if the value stored in the memory block is equal to 5, then condition for the statement would be meant.
Re: Webmasters Enter Here If You Can Solve These PHP Questions... by TechtraGadgets: 4:03pm On Apr 30, 2015
Tobilastik:


where do u learn this?? I need sth like this

Ebooks.
Re: Webmasters Enter Here If You Can Solve These PHP Questions... by Grime: 4:07pm On Apr 30, 2015
codemarshal08:


Name: Ternary Operator it is a short-hand notation for writing conditional statements
($age<15) ? 'Accept': 'Reject';
the above code will return Accept if age is less than 15 Else it returns Reject
Conditional statement. The ternary operator is ?:
Re: Webmasters Enter Here If You Can Solve These PHP Questions... by Horlufemi(m): 4:13pm On Apr 30, 2015
eeya | don't speak PHP cheesy
Re: Webmasters Enter Here If You Can Solve These PHP Questions... by codemarshal08(m): 5:06pm On Apr 30, 2015
Grime:

Conditional statement. The ternary operator is ?:
my bad, I misread the question.
I have made the necessary correction
Thanks.
Re: Webmasters Enter Here If You Can Solve These PHP Questions... by Craigston: 5:09pm On Apr 30, 2015
Terahertz:
It will actually return 3 the initial value but will change the variable $a to 4....
Oh, thanks for notifying me. Yea. The return statement is executed before the increment, just like ++$a and $a++? Thanks again.
Re: Webmasters Enter Here If You Can Solve These PHP Questions... by holyboss: 5:24pm On Apr 30, 2015
brb, let me finish with ds nude babe on my bed first..


btw, check out my signature

Re: Webmasters Enter Here If You Can Solve These PHP Questions... by Craigston: 5:25pm On Apr 30, 2015
cbrass:
$age= 15;
($age<15) ? 'Accept': 'Reject';
Who can explain what this code will do and what's the name of this expression?

Cc jregz craigston
Hey, is that Cbrass? Already answered sha. The ternary operator: it returns 'reject' since $age==15.
Re: Webmasters Enter Here If You Can Solve These PHP Questions... by Craigston: 5:26pm On Apr 30, 2015
cbrass:
$age= 15;
($age<15) ? 'Accept': 'Reject';
Who can explain what this code will do and what's the name of this expression?

Cc jregz craigston
Hey, is that Cbrass? Already answered sha. The ternary operator: it returns 'reject' since $age==15.
Re: Webmasters Enter Here If You Can Solve These PHP Questions... by Craigston: 5:31pm On Apr 30, 2015
Tobilastik:

where do u learn this?? I need sth like this
Google will lead you to good places if you seek well. If you need suggestions, just ask here and someone will reply.
Re: Webmasters Enter Here If You Can Solve These PHP Questions... by adebusola09: 6:30pm On Apr 30, 2015
FRInteractives:
Question 1
Q: What is wrong with this query: "SELECT * FROM table WHERE id = $_POST [ 'id' ]" ?
where id =$_post is wrong instead it shld b like dis $id=$_POST [ 'id' ]" "select * from table where id =$id"
Re: Webmasters Enter Here If You Can Solve These PHP Questions... by adebusola09: 6:35pm On Apr 30, 2015
FRInteractives:
Question 2
Q: What is the preferred way to write this if statement, and why?
if( 5 == $someVar ) or if( $someVar == 5 )
d correct one is : if( $someVar == 5 )
Re: Webmasters Enter Here If You Can Solve These PHP Questions... by bams2999(m): 6:59pm On Apr 30, 2015
if($test == 1){
}else{
}

and

if($test == 1)
echo 'asdsa';
else
Re: Webmasters Enter Here If You Can Solve These PHP Questions... by cbrass(m): 7:00pm On Apr 30, 2015
Craigston:

Hey, is that Cbrass?
Already answered sha. The ternary operator: it returns 'reject' since $age==15.

Yes o. You should be coding well now abi?
Re: Webmasters Enter Here If You Can Solve These PHP Questions... by Craigston: 8:35pm On Apr 30, 2015
cbrass:


Yes o. You should be coding well now abi?
Not yet o. I just started. It's not easy. I've done basics and now I hope to get the real stuff. You know, I just got my pc newly (I bought it from someone), about a month now, and I'm just a beginner.
Re: Webmasters Enter Here If You Can Solve These PHP Questions... by jonezz(m): 8:47pm On Apr 30, 2015
I dor show, let the questions begin
Re: Webmasters Enter Here If You Can Solve These PHP Questions... by Bluemoon1(f): 3:11am On May 01, 2015
teemy:


"SELECT * FROM table WHERE id = $_POST[ 'id' ]" ?
*******************************************************************
Q: What is the preferred way to write this if statement, and why?

if( 5 == $someVar ) or if( $someVar == 5 )
***********************************************************************
Q: Given this code:

function doSomething( &$arg )
{
$return = $arg;
$arg += 1;

return $return;
}
$a = 3;
$b = doSomething( $a );
...what is the value of $a and $b after the function call and why?

$b = 3 because it has the value of the of the inputed variable initial value. The $a was autoincremented after the return variable was assigned
$a = 4 as it has been autoincremented by 1. However only valid within the function ellse undefined if called outsie it.
NB. considering that &$arg is a typo

***********************************************************************
Question 4

Q: Consider these lines of codes:
//first code
$myVar = "I am Something";

$myVar .= "So Special";

echo "Do you Know $myVar";

And
//second code
$myVar = "I am Something";

$myVar .= "So Special";

echo 'Do you Know $myVar';

Now if you run these two codes in a Browser what will be the output?

The same Do you Know $myVar and not Do you Know I am SomethingSo Special
NB. There was no concatenation between string and assumed variable


Correct! I thought I was crazy for a brief moment when some people answered that both a and b wld equal to 4. I was also right about the browser outputting "Do you Know $myVar". I really need to work on my self confidence.

1 Like

Re: Webmasters Enter Here If You Can Solve These PHP Questions... by luthorcorp: 7:21am On May 01, 2015
jdjdb

Re: Webmasters Enter Here If You Can Solve These PHP Questions... by FRInteractives: 8:37am On May 01, 2015
I've been reading through your answers, shit, and contributions. Keep on reading and I will post some more difficult tasks on PHP

(1) (2) (3) (Reply)

How To Start Gsm Short Code Sms Cool Cash Business With A Token Money / Has Anyone Noticed That Ogbongeblog Has Been Down Since? / Why You Are Not Making A Kobo From Your Blog

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 32
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.