Welcome! Log In Create A New Profile

Advanced

Section Eight - Functions

Posted by 77726812Lancevjm 
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
avatar Section Eight - Functions
July 23, 2012 08:32PM
wow! coming from just making static html pages, the "include()" function BLOWS hot smiley MY MIND!!! completed section 8
Re: Section Eight - Functions
July 28, 2012 12:27PM
I am busy reworking functions as a chapter 3 from book excersize does not work, In PHP8 they say you can set two arguments for a function. When I try this I come up with an error

Language: PHP
display_error_message( );   function display_error_message( ) {   $error_text = "Error Detetceted"; print $error_text; }   $this_is_fun="fun -ctions :)";   fun_function($this_is_fun);   function fun_function($this_is_fun) { print "<br>". $this_is_fun; }   $var1="Variable 1"; $var2="Variable 2";   2_arguments($var1,$var2);   function 2_arguments($var1,$var2) { print "This is ". $var1. "and it is an argument. ". $var2. " is also an argument in the same function";   }

What am I doing wrong? I suspect that you cannot use two variables as arguments
Re: Section Eight - Functions
July 28, 2012 12:31PM
Figured it out, I am an airhead...

Cannot start a variable name with a number, works like a dream smiling smiley

Language: PHP
$var1="Variable 1"; $var2="Variable 2";   two_arguments($var1,$var2);   function two_arguments($var1,$var2) { print "This is ". $var1. "and it is an argument. ". $var2. " is also an argument in the same ";   }
Re: Section Eight - Functions
August 07, 2012 10:36PM
Figured out how to pass mutiple results out of a function Php 8 (77683080)

Language: PHP
<?php function add_subt($val1, $val2){ $add = $val1 + $val2; $subt = $val1 - $val2; $result = array($add, $subt); return $result; } $result_array = add_subt(12, 9); print("Add " . $result_array[0] . "<br />"); print("Subtract " . $result_array[1]);   ?>
Re: Section Eight - Functions
August 12, 2012 04:02PM
I also love the include() function. It solves a lot of problems in html.thumbs up
Re: Section Eight - Functions
August 12, 2012 04:09PM
This is very cool!
Re: Section Eight - Functions
August 13, 2012 07:53PM
in my view functions are necessary it makes your code easier to read and modify
Re: Section Eight - Functions
August 14, 2012 03:57AM
Done with functions a while back. They save time considering one can use a function over and over simply by calling it instead of coding each time one needs to use it.
Re: Section Eight - Functions
August 16, 2012 05:52PM
Best part of PHP for me! You can do so much with it: shorter and streamline your code, much neater, reusable... And if you're doing OOP, it's even more powerful!
Re: Section Eight - Functions
September 24, 2012 10:52PM
Completed PHP Eight
Sorry, only registered users may post in this forum.

Click here to login