Welcome! Log In Create A New Profile

Advanced

PHP Two - Getting Started With Variables

Posted by 77928490 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
PHP Two - Getting Started With Variables
February 11, 2013 10:36PM
Pretty straight forward. Strange the term 'BODMAS' was not used at this I thought was general mathematical knowledge.

Section tow done and dusted.
avatar Re: PHP Two - Getting Started With Variables
February 12, 2013 03:56PM
Same here. One of my other programming courses made mention of BODMAS. Giving that my math knowledge is scary!! spinning smiley sticking its tongue out
avatar Re: PHP Two - Getting Started With Variables
February 13, 2013 09:42AM
done also

gbakamela [77234715]
avatar
Mac
Re: PHP Two - Getting Started With Variables
February 13, 2013 10:31AM
77843835AlexB Wrote:
-------------------------------------------------------
> Same here. One of my other programming courses
> made mention of BODMAS. Giving that my math
> knowledge is scary!! spinning smiley sticking its tongue out

That is not used much in general Internet Programming - it is covered in the handbook.
avatar Re: PHP Two - Getting Started With Variables
February 13, 2013 12:04PM
mac Wrote:
-------------------------------------------------------
> 77843835AlexB Wrote:
> --------------------------------------------------
> -----
> > Same here. One of my other programming courses
> > made mention of BODMAS. Giving that my math
> > knowledge is scary!! spinning smiley sticking its tongue out
>
> That is not used much in Internet Programming - it
> is covered in the handbook.


Thanks!! Just hope that Kalahari will hurry up with the delivery of my handbook.
Re: PHP Two - Getting Started With Variables
February 17, 2013 07:46AM
77843835AlexB Wrote:
-------------------------------------------------------
> mac Wrote:
> --------------------------------------------------
> -----
> > 77843835AlexB Wrote:
> >
> --------------------------------------------------
>
> > -----
> > > Same here. One of my other programming
> courses
> > > made mention of BODMAS. Giving that my math
> > > knowledge is scary!! spinning smiley sticking its tongue out
> >
> > That is not used much in Internet Programming -
> it
> > is covered in the handbook.
>
>
> Thanks!! Just hope that Kalahari will hurry up
> with the delivery of my handbook.


Or you could have downloaded the book from piratebay - and go print it if you wanted.
Re: PHP Two - Getting Started With Variables
February 17, 2013 07:49AM
Already finished section 2, haven't run in any problems so far, except for the really dum moment where I couldn't remember you use "<br>" to get a new line
Re: PHP Two - Getting Started With Variables
February 17, 2013 08:37AM
Remembering maths from school days does help... albeit that was a long time ago eye popping smiley

Done and dusted!
Re: PHP Two - Getting Started With Variables
February 18, 2013 03:05PM
ahhh - thank you Sindie, I think i am going to dowload a book in piratebay.
avatar
Mac
Re: PHP Two - Getting Started With Variables
February 18, 2013 03:10PM
Hey.... no pirate bay stuff here.... else I am going to post your portfolio code here for all students to see thumbs up smiley Same thing!
avatar Re: PHP Two - Getting Started With Variables
February 18, 2013 03:17PM
Hahahahaha!!! spinning smiley sticking its tongue out Nice one Mac!!! thumbs up
Re: PHP Two - Getting Started With Variables
February 18, 2013 03:51PM
nooooooooo! ok fine - no piratebay sad smiley
avatar Re: PHP Two - Getting Started With Variables
February 18, 2013 06:12PM
imagine your work making hits on piratebay while you ain't making money angry smiley so please buy original materials copyright infringement ain't cool!

gbakamela [77234715]
Re: PHP Two - Getting Started With Variables
February 18, 2013 08:30PM
PHP two done, seeming that this is the 1st time i am working with PHP and programming as a whole, i battled a little with understanding variable and direct text & variable data, but just red it a few times and did the exercisers, that definitely made it easier.
Re: PHP Two - Getting Started With Variables
February 18, 2013 08:59PM
Exercises done - variables (assigning values to variables, calculation and concatenation) understood. Now on to conditional logic.smile
avatar Re: PHP Two - Getting Started With Variables
February 19, 2013 02:12PM
I wish someone had explained it to me like this when I was in school - I might of actually passed Maths eye popping smiley or maybe the understanding comes with age!

For those struggling with the concept I find this little explanation - I realise that BODMAS is not really used in coding but it still helps me.

B    -> Brackets first
O    -> Orders (ie Powers and Square Roots, etc.)
DM  -> Division and Multiplication (left-to-right)
AS  -> Addition and Subtraction (left-to-right)

____________________________________________Nazi Coder____________________________________________

I'm not antisocial, I'm just not user friendly

"It's not a bug; it's an undocumented feature!" ~ some unknown Microsoft developer
Re: PHP Two - Getting Started With Variables
February 19, 2013 04:25PM
Thanks Shado77968239, wondered what the 'O' in BODMAS stood for.
Re: PHP Two - Getting Started With Variables
February 20, 2013 11:52AM
section two down.. off to section three..

basic math stuff will definitely use this when it comes to data manipulation from a database.

Student number : 7803-010-2
Email and Gtalk for support : wilcovandeijl@gmail.com
avatar Re: PHP Two - Getting Started With Variables
February 22, 2013 05:55AM
Tutorial explains variables quite well. Thanks to forum students for BODMAS, will remember that!
Re: PHP Two - Getting Started With Variables
February 24, 2013 10:59PM
"First, your people (variables) need a dollar sign at the beginning (people are like that)" - haha, we all require money to work.
Found a nice explanation for the reason behind the $ sign in front of variables in php :
http://www.quora.com/PHP/Why-does-PHP-use-to-denote-variables#


Just for interest sake I researched the difference between echo() and print() on php.net
Both are language constructs but unlike echo(), print() behaves like a function and always has a return value of 1.
Re: PHP Two - Getting Started With Variables
February 25, 2013 10:34AM
LOL i like your explanation. I always use echo(), i just thought its more unique for PHP, print() is found everywhere. so whenever i use print() its almost as if i am mixing languages.
your explanation makes sense though.
avatar Re: PHP Two - Getting Started With Variables
February 26, 2013 01:28AM
Section completed. I saved each exercise separately for reference purpose eg: variablesaddition.php, variablesdivide.php, variablesmultiply.php etc. No hitch so far except from EasyPhp installation.
Re: PHP Two - Getting Started With Variables
March 12, 2013 03:51PM
Did Delphi programming at school, Doing Delphi Programming at school, helped me a lot to understand this section. smiling smiley section completed
avatar
Mac
Re: PHP Two - Getting Started With Variables
March 12, 2013 04:58PM
AidenM-77499980 Wrote:
-------------------------------------------------------
> Did variables at school in IT when I did Delphi
> programming, Helped me a lot in this section with
> the understanding. smiling smiley section completed

Sometimes my responses here may not make sense... and why not? I read and read and read 10 hours a day, and therefore I tend to read way too fast... sad smiley

This is how I understood this post when I read it 1st time...!

This section helped you to understand what you did in school smiling smiley smiling smiley
Re: PHP Two - Getting Started With Variables
March 13, 2013 11:28AM
Rewritten, is that a bit better? sorry about that smiling smiley
avatar
Mac
Re: PHP Two - Getting Started With Variables
March 13, 2013 12:16PM
Yes, now my post does not make sense smiling smiley
Re: PHP Two - Getting Started With Variables
March 20, 2013 10:22AM
simalar syntax to c/c++
avatar Re: PHP Two - Getting Started With Variables
March 20, 2013 12:10PM
Do not need Windows Calculator or Excel anymore.grinning smiley

Language: PHP
echo "<td>"Hello World"</td>";

or

Language: PHP
print "<td>"Hello World"</td>";

Which is best? confused smiley
avatar Re: PHP Two - Getting Started With Variables
March 20, 2013 11:28PM
I really like the way variables are declared in PHP.
I noticed that you don't need to specify the data type of the variable.
Semi-colons at the end of each line is normal when you have been coding in C# all this time.
I see that with text variables we can use double or single quotes around the text.
I prefer to use double quotes for text variables.
The syntax for comments is the same as C#.
// - for a single comment line
/* */ - for multi line comments.
The syntax for direct text concatenation is different.
I didn't think the full stop would be used for this purpose.
Addition, Subtraction, Multiplication and Division of numbers is pretty straight forward.
Re: PHP Two - Getting Started With Variables
March 21, 2013 01:54PM
I think it depends on what you want to do.
Echo() is a little bit faster than print() but not enough so that it should matter.
Echo() can take multiple parameters which is useful but you can always just use string concatenation with print().
Print() does however offers you a return value and function behavior which echo() cannot give you.
Perhaps always use echo() - it is after all minutely faster tongue sticking out smiley- except if you need the added functionality that print() offers you.

I went and played around a bit with echo() and print():

Language: PHP
<html> <head> <title> echoVSprint </title> </head> <body> <?php   //$Foo will return as true, print always returns as one $Foo = print ';foo';.';</br>';; if($Foo == true) { print ';true</br>';; } else { print ';false';; }   //$Boo will return as true, print always returns as one $Boo = print ';';; if($Boo == true) { print ';true</br>';; } else { print ';false';; }     //Echo will not work this way, it does not act as an function // // $Joo = echo ';foo';; // if($Joo= true) // { // print ';true';; // } // else // { // print ';false';; // }   $var = ';plant';; //this will work, echo can take multiple parameters: echo ';echo parameters separated by commas=';,';cat';, ';dog';, ';mouse';,1,$var,';</br>';;   //this will not work: // print (';cat';,';dog';,';mouse';);     //this will not work, print works with concatenations of parameters in brackets: print (';print concatenation=';.';cat';.';dog';.';mouse';.';1';.$var.';</br>';);   //echo also works with concatenations of parameters in brackets echo (';echo concatenation=';.';cat';. ';dog';. ';mouse';.';1';.$var.';</br>';);     //useful ways to use print() as a function:   $foo = 1; $foo and print(';ok</br>';) or print(';not ok show an error</br>';);   $boo = 0; $boo and print(';ok</br>';) or print(';not ok show an error</br>';);     //this will not work:   // $foo = 1; // $foo and echo(';ok</br>';) or echo(';not ok</br>';); // // $boo = 0; // $boo and echo(';ok</br>';) or echo(';not ok</br>';);     ?> </body> </html>


The links that I got the information from:
http://stackoverflow.com/questions/234241/how-are-echo-and-print-different-in-php
http://fabien.potencier.org/article/8/print-vs-echo-which-one-is-faster
Re: PHP Two - Getting Started With Variables
March 21, 2013 02:59PM
I got a little side tracked with mantissa in this chapter.
I really wanted to know why floating point numbers should not be trusted in terms of accuracy.
I did't expect that I would be opening such a big can of worms though.
Wiki's explanation was the easiest to understand:
http://en.wikipedia.org/wiki/Floating_point
Sorry, only registered users may post in this forum.

Click here to login