Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 06-20-2005, 09:34 PM   #1 (permalink)
falsepride
Regular Contributor
 
Join Date: Oct 2004
Posts: 209
falsepride is on a distinguished road
predefined function variables. ugh!!

okay i have a function with 3 predefined variables like

function blah($b1 = false, $b2 = "1", $ugh = "i'm stupid")

when i call the function how i can i just use define the second or third variable and use the predifined for the others? i tried blah(, , false); but thats not it.

and heres a random question. i saw other peoples functions on old scripts i downloaded. and they had this function blah2(&$blahblah) whats the & for?
falsepride is offline   Reply With Quote
Old 06-21-2005, 03:07 AM   #2 (permalink)
DJMaze
Senior Contributor
 
DJMaze's Avatar
 
Join Date: Mar 2005
Posts: 676
DJMaze is on a distinguished road
you can't forget the first, you can forget the last though.

If you want to forget the function must work differently like blah($array)

& means you send the data as reference (pointer), If you don't use & the data gets copied.
Code:
<?php

function blah($var) {
    $var = 'no reference';
}
function ref(@$var) {
    $var = 'reference';
}

$a_var = 'a string';
blah($a_var);
echo $a_var;

ref($a_var);
echo $a_var;
this will output:
Code:
a string
reference
DJMaze is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Function returning pointer lostromos Standard C, C++ 3 04-19-2005 02:34 AM
Search function with its own database Sonny1973 HTML, XML, Javascript, AJAX 3 03-28-2005 03:52 PM
pass filename to function Blaqb0x Standard C, C++ 1 09-02-2002 10:12 PM


All times are GMT -8. The time now is 10:27 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting