Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,162,107 members, 7,849,452 topics. Date: Monday, 03 June 2024 at 09:52 PM

Ify01's Posts

Nairaland Forum / Ify01's Profile / Ify01's Posts

(1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (11) (12) (13) (14) (of 14 pages)

Webmasters / HELP: My WP Posts Redirects To A Page by ify01: 12:15am On Sep 17, 2017
I tried clicking on a post (as a guest) in a website i manage, and i notice it redirects to a particular page within the website.

But if logged in as an admin, I could get access to the post - able to read the post

i.e if i click the link to any of the posts, it redirects me to the 'About Us' page.

below is the redirect link (after clicking on post link):

http://dlcfua.ml/about/?redirect_to=http%3A%2F%2Fdlcfua.ml%2Funiabuja-post-utme-procedure-20172018%2F

Please oh, what could be wrong? I've disabled plugins, access my ftp, but nothing seem to be working.

Abeg, help a brother - what's the problem?

1 Like

Programming / Re: What's Wrong With This Code? by ify01: 6:07pm On Mar 09, 2017
hotwax:
Your braces are killing...Use a better construct like switch...case

However, send us the error message, that can help us to help u
Thanks. I would appreciate if you can give me a sample of using switch . . .
Programming / Re: What's Wrong With This Code? by ify01: 6:05pm On Mar 09, 2017
Donald3d:
first of all I had a hard time reading your if statement,use switch next time.My head hurts
if you dont want to use switch just use AND/OR to combine all of them
In your html the p tag was not closed
Also the input tag close it

Modified
Where you have $ch3="checked.......
You missed the second apostrophe.

Thanks. The error was as a result of the apostrophe. you said something about switch. . . i would appreciate a sample of how I can use switch or AND/OR as per this code.
Programming / What's Wrong With This Code? by ify01: 1:06pm On Mar 09, 2017
Please can someone figure out the problem with this code? it just keeps displaying errors.

<html>
<head>
<?php
$ch1 = " unchecked";
$ch2 = "unchecked";
$ch3 = "unchecked";
$ch4 = "unchecked";
$ch5 = "unchecked";
if (isset($_POST["submit1"]))
{
if (isset($_POST["ch1"]))
{
$ch1 = $_POST["ch1"];
if ($ch1 == "word"wink
{$ch1 = "checked";}
}

if (isset($_POST["ch2"]))
{
$ch2 = $_POST["ch2"];
if ($ch2 == "key"wink
{$ch2 = "checked";}
}
if (isset($_POST["ch3"]))
{
$ch3 = $_POST["ch3"];
if ($ch3 == "excel"wink
{$ch3 = "checked;}
}
if (isset($_POST["ch4"]))
{
$ch4 = $_POST["ch4"];
if ($ch4 == "corel"wink
{$ch4 = "checked";}
}
if (isset($_POST["ch5"]))
{
$ch5 = $_POST['ch5'];
if ($ch5 == "power"wink
{$ch5 = "checked";}
}
}

?>
</head>
<body>
<form name = "form1" method = "post" action = "checkbox.php">
<input type = "Checkbox" name = "ch1" value = "word" <?php print $ch1; ?> >Msword
<P>
<input type = "Checkbox" name = "ch2" value = "key" <?php print $ch2; ?> >Passkey
<P>
<input type = "Checkbox" name = "ch3" value = "excel" <?php print $ch3; ?> >Excel
<P>
<input type = "Checkbox" name = "ch4" value = "corel" <?php print $ch4; ?> >Coreldraw
<P>
<input type = " Checkbox" name = "ch5" value = "power" <?php print $ch5; ?> >Powerpoint
<P>
<input type = "submit" name = "submit1" value = "Select your choices">
</form>
</body>
</html>
Education / How relevant is entrepreneurship studies to you as a student? by ify01: 11:48pm On Feb 24, 2017
With the present economic realities in the country today, and considering the fact? that there are no jobs waiting for anyone outside; what then, in your opinion, could be the relevance of entrepreneurship studies to you ( or as it relates to your field of study)?
Programming / Re: I Need A Forum Blog - Who Can Help Me? by ify01: 4:28pm On Jan 13, 2017
Rocketmaster:
Good Day Programmers, Please Can Someone Who Is Trusted Help Me Create A Forum Blog Like Nairaland, Nct, Quora, Please If You Can Help Contact Me On +2348075884846 But Am Broke O And I Can Only Give Out 1year Paid Host And A Domain - Codedsocrate.com Or Gold9jagist.com.ng As A Form Of Payment...
I can. . . Are you still interested?
Education / Re: University Of Abuja 2017/2018 Admission Updates by ify01: 8:51pm On Nov 28, 2015
I paid my school fees online via ATM, the amount was debited from account but the payment is not reflecting on the portal. What should i do?
Education / Re: University Of Abuja 2017/2018 Admission Updates by ify01: 9:44am On Nov 23, 2015
please what is the designated bank for faculty of arts
Religion / If Only Christians Pray by ify01: 9:47am On Oct 06, 2015
IF ONLY CHRISTIANS CAN PRAY

With the happenings in the nation today and considering the events that pervaded both the pre-election, election and post-election periods and not also forgetting the permutations, predictions and threats that flew around and also the resultant palpable tension, one can’t help but wonder if the nation actually have a future together or if the woes experienced are as a result of the 1914 amalgamation and can only be resolved by the division of the country. Different questions are being asked about the possible reasons for the perceived woes, different answers given and different solutions proffered by different people from different disciplines.

However, with all these events and questions being asked, one exceptional question stands out which requires more than the conventional “yes” or “no”. The question which is quite common is “Are you a Christian” and “where are the Christians?” Yes, where are the Christians while all these things are happening or have they lost their salt because they are known for something. But before we go further, let the tables now turn, so answer the question “Are you a Christian?” Wait! What did you just say? Yes? If so when was the last time you prayed for Nigeria? I don’t get it and so it is possible I am wrong, but do you mean you can’t remember? I am not asking about the day when your pastor, president or General Coordinator called for a group prayer but the day when you individually prayed for Nigeria. And don’t even think of lying because am right behind you! The second question now is when was the last time you prayed for yourself? I believe you can remember this without an hitch. So the question that actually comes up next is “Why do Christians find it hard praying for Nigeria?” Yes, why do they? Because even the unbelievers, the Muslims, the heathens have heard famous bible stories of Daniel and how the holy ones demanded for a “thing” and it was decreed by the watchers. Even the Muslims and Hindus have read stories of Martin Luther and Savanarola who through prayers brought changes to their country. Why Christians do finds it hard praying for Nigeria? Are there even Christians? If yes, where are they? These questions might be seen as philosophical and indeed paradoxical because when examined more closely, one finds out that there is more to it than just a conventional answer.

With the stories of bloodshed, bombings, crisis and other tragedies which were once alien to the nation but which now have become a part of the nation daily affairs, one still finds it hard to believe that there are Christians. If so, where are they? Where are they in the face of all these challenges? Don’t they realize that the nation has need of them? They claim to have a God that answer but why can’t them pray? Infact where are the people you call Christians? Are they not the ones found daily at the cinemas and buses who argue sometimes blindly about frivolous issues or about the political landscape of Nigeria? The above question might be wrong, but are they the same people who are being accused of receiving bribe, compromise and other social and moral vices? I stand to be corrected, but if am wrong, where are they?

One obvious but painful fact is that the acclaimed Christians have left one of their most important tasks which even their master have commanded them when he said “ Pray without ceasing” to engage in other activities that’s why the Muslims and heathens always find them engaging in vices. They don’t pray. They find it hard praying for Nigeria. I make bold to say that the Christians and indeed the church have failed Nigeria because if there is any other time the nation needs them most is now at this trying times when the unity of the nation is at stake. Now when it looks as if things are falling apart. Yes now! They are needed to pray and not to engage in frivolous activities and compromise. They pray for themselves but why do them find it hard praying for Nigeria? Or maybe Christians are not expected to pray for their countries or is it against their biblical laws? But inspiring stories have been told about the exploits of Elijah, Elisha, Girolamo Savonarola, John Hyde and Jonathan Goforth and what they did for their respective nations. Or maybe they are not Christians? If they are, why is the one of Nigeria different? Or maybe Nigeria doesn’t have Christians? If she does, why don’t they pray for her? Don’t they know that the nation is falling apart?

It looks quite disgusting and indeed irritating when we find the Christians alleging plans of islamization. It’s even worse, when they say Nigeria can’t be Islamized. They are very good when speaking based on arguments on this “Islamization Plot”. They are more specialized in interpreting islamization attempts and are even vocal about it. It sounds even scarier when they fail to note that without them praying for Nigeria, all their speeches are like a leaking basket that can’t hold water. If only they can pray, they wouldn’t bother about any islamization threat because they know it will never happen. They wouldn’t bother about the rumours on the incessant killing of Christians because they know that they are safe. They wouldn’t even bother when there is an economic recession because they are assured it will never come near them. But this is if only they pray for Nigeria. But they don’t pray! And even when they do, they are not serious about it and are very much impatient about results. The biggest challenge in the church is impatience and the biggest problems in Nigeria are Christians who don’t pray for their nation. But on a more personal note, when last do you pray for Nigeria? When was the last time you prayed for yourself? Be sincere!

It will be an injustice and therefore very wrong to say that all Christians don’t pray for Nigeria but it would also be pertinent to note that on a scale of ten, eight Christians don’t pray for their Nation, four percent finds it hard praying and of the two percent that pray, one percent pray only when there is need to do so or when told by their leaders to pray. Prayer as used in this context means praying on an individual level and not on group basics; not when called by the leaders or when there is an obvious need to do so.

Moreover, if we now reading this will want to be sincerely frank with ourselves, or if for the purpose of clarity will find it pertinent to do an ‘environmental check’ and ask around, it would be quite obvious and also interesting to note that most Christians for reasons best known to them finds it more easier or rather convenient praying for themselves than for the nation. They most times don’t care about what goes on in the nation as they considered it none of their business and even when called to prayer for specific issues affecting the country by their leaders, they are very reluctant to go most times complaining about what the nation has to give them. They most times do forget the words of John Kennedy when he said that “Don’t ask what your country can give you instead ask what you can give your country”. They pray but they don’t pray about what they were asked to pray for – they convert it to prayers for themselves, their families or their academics. They don’t pray for Nigeria. But why do Christians find it praying for Nigeria? Do you have any idea? As a matter of fact, it is quite clear and obvious that it is not against their biblical laws having read and heard of Christians who helped and prayed for their nation even in the bible. There must surely be another reason for that! Are you a Christian? If yes, why then do you find it hard praying for Nigeria? Air your views so as not to be lost in the forest of righteous curiosity.

The purpose of this article is not to make mockery of Christians or the Christian faith but to awaken them to the fact that they have an important role to play in the country – to pray for the country and that if there is anything the nation needs now is prayerful prayers from prayerful Christians. “Christians pray for us” has always been the cry of the heathen. Are you a Christian? Will you pray? Please do.

If only Christians can pray, a lot of changes would be effected in the nation. If only Christians pray, most of the tragedies that befall the nation and always make headlines would have been averted. Is it the abduction in Borno? The bombings in Enugu or the motorcycle crash in Benue? If only Christians can pray, gory stories of horrible killings will not make headlines. Nigeria prays! We do know that not all Christians don’t pray for Nigeria, but how happy would it be if every one of them does pray individually and wholeheartedly without being called to function by their leaders. If only Christians pray, they would not bother about islamization threats knowing that it can never happen. If only they agree to pray, a lot of problems being faced today as a nation would be corrected knowing fully well that their master has given them authority and tasked them to “pray without ceasing”. Christians pray, the nation needs you. The welfare of Nigeria is the collective responsibility of every Christian. Pray for Nigeria as you pray for yourself because anything that affects it will surely affect you. It is agreed that you may have money to readily fly out in the event of any trouble. But what about your immediate and extended family, your friends and loved ones or even your properties and investments? Will you take them along? Think about those who will have nowhere to run to: those who don’t even have money to go to the next town. What would they do? Are you a Christian? If yes, when was the last time you prayed for Nigeria? Long time ago? No problem, it’s not too late, you can start praying now. The Nation needs and values your prayer. If there is any time that the Country has a need of your prayers is NOW. Please pray for Nigeria. Join the clarion call and pray for Nigeria. Don’t wait for your leaders or till something is rumoured to happen and a group prayer is urgently called. You don’t have to wait because you can start praying now. Please pray for Nigeria. Will You?

Credits to: BRYKT FORUMS
Education / Re: University Of Abuja 2017/2018 Admission Updates by ify01: 8:04pm On Sep 18, 2015
please is hostel application over?
Politics / Re: Amaechi Declares Curfew In Rivers State by ify01: 7:59pm On Mar 30, 2015
noskeybaba:
Tension everywhere. Even for my yard tension dey. Them don form factions, Igbos dey one corner dey discuss the results so far, Yorubas dey another corner, we dey eye ourselves, My Landlord na APC chieftain, guy!! As I'm writing this I'm under siege! men dem don gather weapon for self defense just incase of any fracas I won't be caught unawares. My problem na oga Landlord, he fit throw men dem out this night. No matter what Nigeria will still stand.
One Nigeria

1 Like

Politics / Re: General Buhari And His Wife Being Accredited (photos) by ify01: 1:43pm On Mar 28, 2015
One Nigeria
Politics / Nigeria, United States In Fresh Face-off by ify01: 9:22am On Dec 14, 2014
The face-off between Nigeria and the United States over the commitment and sincerity of the US military in assisting Nigeria to fight the Boko Haram insurgency worsened within the week.

This followed an allegation by a top Nigerian intelligence source that US trainers incited Nigerian soldiers to mutiny.

The source told SUNDAY PUNCH that recent mutiny by Nigerian soldiers was as a result of the ‘negative teachings’ by US trainers, adding that it was a major reason the Federal Government stopped the US from training Nigerian soldiers on counter-terrorism.

But the US in its reaction, through the Press Attache of the US Embassy in Abuja, Sean J. McIntosh, described the allegations as baseless.
She said, “The allegations are baseless. The third phase of training did not occur because the Nigerian Army failed to provide the necessary equipment for the training.”

The US, as well as the UK, France and China, had offered help in human and technical capacities to deal with the wider problem of terrorism in North-eastern Nigeria.

But the relationship between the two countries worsened when the US refused to sell military hardware, especially cobra helicopters, to Nigeria to prosecute the campaign against Boko Haram.

The security source, who pleaded anonymity, said the security chiefs and the Federal Government doubted the genuineness of the motive of the US security experts in the country.

The source added that despite the presence of the US experts, there was no noticeable impact on the task of recovering the abducted girls of the Government Girls Secondary School, Chibok.

He added that the US forces had not given the expected intelligence that could have been utilised by the nation’s security forces against Boko Haram.
“Our investigations show that some of the soldiers that were involved in mutiny received training in the US. These trainings often highlight negative things about the Federal Government.

“Another thing Nigerians should note is that since the Americans came here purportedly to help get the Chibok girls, they have not done anything. What have they done with all their technology and might? Is it not suspicious?”

When asked if the US would be asked to withdraw its intelligence staff from Nigeria, the source said, “They are a super power. It might not be easy to tell them to leave.”

But the US embassy spokesman said his country had not received any directive or request from Nigeria to withdraw its intelligence personnel who were brought into the country to assist with the rescue of the abducted Chibok school girls
He said, “The US continues to support Nigerian efforts to bring about the safe recovery of those kidnapped and to advise the Nigerian government on its response. Staffing of the US government interdisciplinary team in Nigerian remains steady since the initial surge following the kidnapping.”

PUNCH NG/
Politics / Re: Nigeria Government terminates US Military Training Of Army by ify01: 8:32pm On Dec 01, 2014
ujoinme:
The USA are praying and hoping Nigeria fails so they can plunder what is left of our crude oil, Like they are doing in irag and libya, They are doing everything to help distabilize Nigeria. But Nigeria will not fail.
I love those words in Bold.

1 Like

Education / Re: University Of Abuja 2017/2018 Admission Updates by ify01: 7:49pm On Nov 03, 2014
Righteour:
Check the school website
I Didn't see any info related to that on - uniabuja.edu.ng . Can you provide a link to where i can find it?
Education / Re: University Of Abuja 2017/2018 Admission Updates by ify01: 8:17am On Nov 03, 2014
How do one know the designated bank for each department?
Programming / Re: Help With Login Form by ify01: 12:13am On Oct 12, 2014
yousouphe:
yes bro still good but this one is taking too long u could just use loop to solve the problem instead of the index( 0123) urself, u could save urself that time by using loop
Thanks
Noted! Thanks for that advice.
Programming / Re: Help With Login Form by ify01: 12:11am On Oct 12, 2014
drealboy:

<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<?php
$users = array('john','paul','mark','luke');
$admin = array('dan','ify','chris','jane');
if(!isset($_POST['submit1'])){
?>
<form name="trial" action="<?php echo $_SERVER['PHP_SELF']?>" method="POST">
<input type="text" name="paul" value="">
<input type="submit" name="submit1" value="Enter">
</form>
<?php
}else{
$june = $_POST['paul'];
$member = "Sorry but you are not recognized in our database";
for($i =0; $i< 4; $i++){
if($june==$users[$i]){
print "Welcome";
break;
}
if($june==$admin[$i]){
print "welcome back super admin";
break;
}
if($i==3){
print $member;

}
}
}
?>
</body>
</html>

Thanks for helping out.
Programming / Re: Help With Login Form by ify01: 5:18pm On Oct 07, 2014
drealboy:

wrapping d conditions in <for loop> would av produced a cleaner codes …too many logical operators der is just too unreadable
please, can you give me a sample code?
Programming / Re: Help With Login Form by ify01: 11:59am On Oct 07, 2014
mubitechnology:
pls let us not turn this thread into a fight arena, let try and provide solution the op problem, I believe we are all professionals here .

If 98% of people are like you, i believe that the world would be a better place. Thanks for replying.
Programming / Re: Help With Login Form by ify01: 11:45am On Oct 07, 2014
spicyuzo:


Oga boss clap for yourself...

How have you contributed positively to this thread?

When did it become a crime to ask questions?

Didn't you pass through a learning proccess, or you were preloaded with php knowledge from birth?
The op is here asking for help.
If you can help if you cannot, stay put.


Op, try out the solution proffered by the yousouphe.

You have to refrence the position index.

Consult more books for better enlightenment.
I have tried that! Thanks for replying
Programming / Re: Help With Login Form by ify01: 11:33am On Oct 07, 2014
yousouphe:

Its not possible u call on array like a normal variable u could use indexing to get the actual array element something like $user[0] still better to get the index , u could use loop.
But try it this way


For (a =0;a<=3;a++)
{
if ($june == $users[a]) {print ('welcome'); }

if ($june == $admin[a]) {print ('Welcome back, SuperAdmin'); }

else {print ($members);
}

Thanks for replying. What do you think about the below code?

<html>
<head>
<?php
$users = array('john', 'paul', 'mark', 'luke');


$admin = array('dan', 'ify', 'chris', 'jane');
if (isset($_POST['submit1'])) {$june = $_POST
['paul'];


$members = 'Sorry,but you are not recognised in our database';}


if ($june == $users[0] || $june == $users[1] || $june == $users[2] || $june == $users[3]){print ('welcome'); }


else if ($june == $admin[0] || $june == $admin[1] || $june == $admin[2] || $june == $admin[3]) {print ('Welcome back,
SuperAdmin'); }

else {print ($members);
}
?>
</head><body>


<form name = 'trial' method = 'post' action =
'<?php $_SERVER[PHP_SELF];?>'>


<input type = 'TEXT' Name = 'paul' value = 'user'>


<input type = 'submit' value = 'enter' Name =
'submit1'>
</body>
</form>
</html>
Programming / Help With Login Form by ify01: 4:01am On Oct 07, 2014
Am Trying to create a form with array(); in which users can log in . The problem am having is that when ever i call the array(); i.e $users into
function, it dislays wrong members ID. How do i correct this? Please a detailed analysis and if possible a sample code would be appreciated.

<html>

<head>

<?php

$users = array('john', 'paul', 'mark', 'luke');

$admin = array('dan', 'ify', 'chris', 'jane');

if (isset($_POST['submit1'])) {$june = $_POST['paul'];

$members = 'WRONG ID'; }

if ($june == $users) {print ('welcome'); }

if ($june == $admin) {print ('Welcome back, SuperAdmin'); }

else {print ($members);
}

?>

</head><body>

<form name = 'trial' method = 'post' action = 'trial.php'>

<input type = 'TEXT' Name = 'paul' <?php print $june . ' '; ?> value = 'user' ?>

<input type = 'submit' value = 'enter' Name = 'submit1'>

</body>

</form>

</html>
Programming / Re: Help A Newbie Php Programmer by ify01: 3:57am On Oct 07, 2014
Djangocode:
Variables and Arrays are quite easy to understand... Do u have a good book on php, You can email me for one... You dont need to declare a variable type in php before assigning a value to it.. Eg:
$age = 13;
$name = "tom";
echo $age;
echo $name;

This outputs 13 and tom respectively...

Just think of Variables as a container for an object and think of Arrays as a container for various objects or values..

If u are on bbm, U can add me for further questions u might have... Hope my explanation helped..
Are you on Fb?
Programming / Re: An Introduction To PHP - Beginners Base by ify01: 12:46pm On Oct 01, 2014
10. floating point numbers

A floating point number is one that has a dot in it, like 0.5 and 10.8. You don't need any special syntax to set these types of numbers up.


Here's an example for you to try:


<?php
$first_number = 1.2;
$second_number = 2.5;
$sum_total = $second_number $first_number;
print ($sum_total);
?>


You add up, subtract, divide and multiply these numbers in exactly the same way as the integers you've been using. A warning comes with floating point numbers, though: you shouldn't trust them, if you're after a really, really precise answer!


Some Exercises


To round up this section on number variables, here's a few exercises (In your print statements, there should be no numbers – just variable names):

Exercise


Write a script to add up the following figures: 198, 134, 76. Use a print statement to output your answer.

Exercise


Write a script to add up the following two numbers: 15, 45. Then subtract the answer from 100. Use a print statement to output your answer.

Exercise


Use variables to calculate the answer to the following sum:
(200 * 15) / 10
Use a print statement to output your answer.

In our next section, we'll take a look at Conditional Logic.

LOST? Drop your queries b4 i countinue
Programming / Re: An Introduction To PHP - Beginners Base by ify01: 8:12am On Oct 01, 2014
9. Division in PHP

To divide one number by another, the / symbol is used in PHP. If you see 20 / 10, it means divide 10 into 20. Try it yourself:

<?php

$first_number = 10;

$second_number = 20;

$sum_total = $second_number / $first_number;

print ($sum_total);

?>

Again, you have to be careful of operator precedence. Try this code:

<?php

$first_number = 10;

$second_number = 20;

$third_number = 100;

$sum_total = $third_number - $second_number / $first_number;

print ($sum_total);

?>

PHP won't work out the sum from left to right! Division is done before subtraction. So this will get done first:

$second_number / $first_number

And NOT this:

$third_number - $second_number

Using parentheses will clear things up. Here's the two versions for you to try:

Version one

$sum_total = $third_number - ($second_number / $first_number);

Version two

$sum_total = ($third_number - $second_number) / $first_number;

The first version will get you an answer of 98, but the second version gets you an answer of 8! So remember this: division and multiplication get done BEFORE subtraction and addition. Use parentheses if you want to force PHP to calculate a different way.



In the next part, we'll take a look at how PHP handles floating point numbers.
Programming / Re: An Introduction To PHP - Beginners Base by ify01: 7:41am On Oct 01, 2014
8. Multiplication in PHP

To multiply in PHP (and just about every other programming language), the * symbol is used. If you see 20 * 10, it means multiply 20 by 10. Here's some code for you to try:

<?php

$first_number = 10;

$second_number = 20;

$sum_total = $second_number * $first_number;

print ($sum_total);

?>

In the above code, we're just multiplying whatever is inside of our two variables. We're then assigning the answer to the variable on the left of the equals sign. (You can probably guess what the answer is without running the code!)

Just like addition and subtraction, you can multiply more than two numbers:

<?php

$first_number = 10;

$second_number = 20;

$third_number = 100;

$sum_total = $third_number * $second_number * $first_number;

print ($sum_total);

?>

And you can even do this:

$sum_total = $third_number * $second_number * 10;

But try this code. See if you can guess what the answer is before trying it out:

<?php

$first_number = 10;

$second_number = 2;

$third_number = 3;

$sum_total = $third_number + $second_number * $first_number;

print ($sum_total);

?>

What answer did you expect? If you were expecting to get an answer of 50 then you really need to know about operator precedence! As was mentioned, some operators (Math symbols) are calculated before others in PHP. Multiplication and division are thought to be more important that addition and division. So these will get calculated first. In our sum above, PHP sees the * symbol, and then multiplies these two numbers first. When it works out the answer, it will move on to the other symbol, the plus sign. It does this first:

$second_number * $first_number;

Then it moves on to the addition. It doesn't do this first:

$third_number + $second_number

This makes the parentheses more important than ever! Use them to force PHP to work out the sums your way. Here's the two different version. Try them both:

Version one

$sum_total = $third_number + ($second_number * $first_number);

Version two

$sum_total = ($third_number + $second_number) * $first_number;

Here's we're using parentheses to force two different answers. PHP will work out the sum between the parentheses first, and then move on to the other operator. In version one, we're using parentheses to make sure that PHP does the multiplication first. When it gets the answer to the multiplication, THEN the addition is done. In version two, we're using parentheses to make sure that PHP does the addition first. When it gets the answer to the addition, THEN the multiplication is done.



In the next part, we'll take a look at division.
Programming / Re: An Introduction To PHP - Beginners Base by ify01: 6:21am On Oct 01, 2014
7. Subtraction in PHP


I Am not going to weigh things down by subjecting you to torrents of heavy Math! But you do need to know how to use the basic operators. First up is subtracting.



To add up using PHP variables, you did this:

<?php

$first_number = 10;

$second_number = 20;

$sum_total = $first_number $second_number;

print ($sum_total);

?>

Subtraction is more or less the same. Instead of the plus sign ( ), simply use the minus sign (-). Change your $sum_total line to this, and run your code:

$sum_total = $second_number - $first_number;

The s$sum_total line is more or less the same as the first one. Except we're now using the minus sign instead (and reversing the two variables). When you run the script you should, of course, get the answer 10. Again, PHP knows what is inside of the variables called $second_number and $first_number. It knows this because you assigned values to these variables in the first two lines. When PHP comes across the minus sign, it does the subtraction for you, and puts the answer into the variable on the left of the equals sign. We then use a print statement to display what is inside of the variable.

Just like addition, you can subtract more than one number at a time. Try this:

<?php

$first_number = 10;

$second_number = 20;

$third_number = 100;

$sum_total = $third_number - $second_number - $first_number;

print ($sum_total);

?>

The answer you should get is 70. You can also mix addition with subtraction. Here's an example:

<?php

$first_number = 10;

$second_number = 20;

$third_number = 100;

$sum_total = $third_number - $second_number $first_number;

print ($sum_total);

?>

Run the code above. What answer did you get? Was it the answer you were expecting? Why do you think it printed the number it did? If you thought it might have printed a different answer to the one you got, the reason might be the way we set out the sum. Did we mean 100 - 20, and then add the 10? Or did we mean add up 10 and 20, then take it away from 100? The first sum would get 90, but the second sum would get 70.

To clarify what you mean, you can use parentheses in your sums. Here's the two different versions of the sum. Try them both in your code. But note where the parentheses are:

Version one

$sum_total = ($third_number - $second_number) $first_number;

Version two

$sum_total = $third_number - ($second_number $first_number);

It's always a good idea to use parentheses in your sums, just to clarify what you want PHP to calculate. That way, you won't get a peculiar answer!

Another reason to use parentheses is because of something called operator precedence. In PHP, some operators (Math symbols) are calculated before others. This means that you'll get answers that are entirely unexpected! As we'll find out right now in the next part - Multiplication.
Programming / Re: An Introduction To PHP - Beginners Base by ify01: 9:58pm On Sep 24, 2014
6. Addition in PHP

OK, let's do some adding up. To add up in PHP, the plus symbol ( ) is used. (If you still have the code open from the previous page, try changing the full stop to a plus symbol. Run the code, and see what happens.)

To add up the contents of variables, you just separate each variable name with a plus symbol. Try this new script:

<?php

$first_number = 10;

$second_number = 20;

$sum_total = $first_number $second_number;

$direct_text = 'The two variables added together = ';

print ($direct_text . $sum_total);

?>

In the above script, we've added a second number, and assigned a value to it:

$second_number = 20;

A third variable is then declared, which we've called $sum_total. To the right of the equals sign, we've added up the contents of the first variable and the contents of the second variable:

$sum_total = $first_number $second_number;

PHP knows what is inside of the variables called $first_number and $second_number, because we've just told it in the two line above! It sees the plus symbol, then adds the two values together. It puts the answer to the addition in the variable to the left of the equals sign (=), the one we've called $sum_total.

To print out the answer, we've used concatenation:

print ($direct_text . $sum_total);

This script is a little more complicated than the ones you've been doing. If you're a bit puzzled, just remember what it is we're doing: adding the contents of one variable to the contents of another. The important line is this one:

$sum_total = $first_number $second_number;

The addition to the right of the equals sign gets calculated first ($first_number $second_number). The total of the addition is then stored in the variable to the left of the equals sign ($sum_total =).

You can, of course, add up more than two numbers. Try this exercise.



Exercise

Add a third variable to your code. Assign a value of 30 to your new variable. Put the sum total of all three variables into the variable called $sum_total. Use concatenation to display the results. (In other words, add up 10, 20, and 30!)



You don't have to use variable names to add up. You can do this:

print (10 20 30);

Or even this:

$number = 10;

print ($number 30);

But the point is the same - use the plus symbol ( ) to add up.



In the few next parts, you'll learn how to Subtract, Divide and Multiply.
Programming / Re: An Introduction To PHP - Beginners Base by ify01: 9:03pm On Sep 24, 2014
luckynzo: Op. Great job u are doing. I hav AMPPS. Can i use it as i already have it installed on my system instead of downloading the WAMP server?
If u are sure that it can cope with the tutorial
Programming / Re: An Introduction To PHP - Beginners Base by ify01: 1:20am On Sep 20, 2014
hushmail:

isn't it obvious?

D sections u skipped
Bro, am sorry i can't post those sections to aviod being banned. You can read it here - Installing and Testing Wampserver

(1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (11) (12) (13) (14) (of 14 pages)

(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. 106
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.