function

how to get function name inside a function in PHP?

Is it possible? function test() { echo "function name is test"; } ...

Javascript : accessing function arguments generically

Here is what I have : var log = function(arg1, arg2){ console.log("inside :" + arg1 + " / " + arg2); }; var wrap = function(fn){ return function(args){ console.log("before :"); fn(args); console.log("after :"); } }; var fn = new wrap(log); fn(1,2); It is wrong, because I'd like to get in the console : b...

phpeclipse: jump to function definition?

from zend's IDE i know that Ctrl+left click on a function name opens the corresponding source file and jumps to the functions definition is there anything similar in eclipse especially phpeclipse OR CDT? im not sure if its just a window->preferences setting i dont see OR some kind of source code indexing i may have disabled which also d...

JavaScript function aliasing doesn't seem to work

I was just reading this question and wanted to try the alias method rather than the function-wrapper method, but I couldn't seem to get it to work in either Firefox 3 or 3.5beta4, or Google Chrome, both in their debug windows and in a test web page. Firebug: >>> window.myAlias = document.getElementById function() >>> myAlias('item1') >...

(C#) why does Visual Studio say it's an object while GetType says it's a Func<object> ?

Hi, C# newbie question here. The following code (taken from the book "C# From Novice to Professional" by Christian Gross, Apress) gives an error: worksheet.Add("C3", CellFactories.DoAdd(worksheet["A2"], worksheet["B1"])); The reason is that the method DoAdd() does not accept the given arguments. public static Func<object> DoAdd(Func...

What is the best-practice casing style for javascript? Why?

One aspect of javascript that it's hard to find information on is casing practices. By casing practices, I mean what casing style (ie. camel-case, pascal-case, etc) should be used for what elements (Constructors, private functions, public functions). The only rule I've heard was from a Douglas Crockford lecture on YUI theater, stating ...

PHP function doesn't return value

I have a function which, given a filename and directory path, checks if the directory already contains a file with the same name and if so returns an amended filename (by appending a number after the first part of the filename). (The get_filenames() function is a CodeIgniter helper function which creates an array of all the filenames in ...

How can I call javascript functions and pass values from xaml/silverlight?

I'm creating silverlight without visual studio. I just have raw html, xaml, and js (javascript). What I want to do is pass values from the xaml to the javascript. I can call and activate javascript functions from xaml. See below. The canvas element has a mouse left button up event that callls LandOnSpace in the javascript. But ho...

Can a bash function be used in different scripts?

I've got a function that I want to reference and use across different scripts. Is there any way to do this? I don't want to be re-writing the same function for different scripts. Thanks. ...

Whats the advantage of using a constructor function in a JavaScript object?

What's the advantage of using a constructor function like so: var MyLibrary = new function(){ var self = this; self.MyLibrary = function(){ // init code } } Instead of simply writing code inside the object? var MyLibrary = new function(){ // init code } ...

Function name conflict in php from 2 different libraries

I have 2 'libraries' which I need to include on the same page. Simple Machine Forums and Wordpress. However both have the function is_admin() which conflicts with each other. Fatal error: Cannot redeclare is_admin() (previously declared in /home/site.com/wordpress/wp-includes/query.php:100)in /home/site.com/smf/Sources/Security.php on ...

Parameter Checks vs Function Call Overhead

Hello, I have a public function that needs to check the validity of a few parameters, but this function is also used internally in a few others places in which I know that the given parameters will be valid. Thus, I'm wondering, which is more costly: 1) Leave the validity checks in every public function, or 2) Do the validity checks in...

Why C# is not allowing non-member functions like C++

C# will not allow to write non-member functions and every method should be part of a class. I was thinking this as a restriction in all CLI languages. But I was wrong and I found that C++/CLI supports non-member functions. When it is compiled, compiler will make the method as member of some unnamed class. Here is what C++/CLI standard ...

How to use "return-path" in php mail function

What is that return path for? Can i Use in this way? mail($to_address, $subject, $message, $headers, "-f".$return_path ); Where: $return_path = "C:/www/project/handlebounceemail.php"; Additional: How to direct the email to a php script? I want to read the email and check for errors. ...

Querying by type in DB4O

How do you pass a class type into a function in C#? As I am getting into db4o and C# I wrote the following function after reading the tutorials: public static void PrintAllPilots("CLASS HERE", string pathToDb) { IObjectContainer db = Db4oFactory.OpenFile(pathToDb); IObjectSet result = db.QueryByExample(typeof("C...

C++ function overriding

I have three different base classes: class BaseA { public: virtual int foo() = 0; }; class BaseB { public: virtual int foo() { return 42; } }; class BaseC { public: int foo() { return 42; } }; I then derive from the base like this (substitute X for A, B or C): class Child : public BaseX { public: int foo() { return ...

How to create wordpress like functions in PHP?

Howdy, To pass variables into functions, I do the following (as other people I'm sure): function addNums($num1, $num2) { $num1 + $num2; } addNums(2, 2); My question is how would I structure a function to act like Wordpress: wp_list_categories('title_li='); Essentially I am looking for a way to create a key/value pair in my fu...

What happens when an inline function is passed as a parameter in C?

Today I was writing some C code to sort an array of structs using quicksort with a custom comparator function to determine their ordering. At first I wrote it with the call to the comparator function hard-coded into the quicksort function. Then I thought perhaps it would be nicer to pass that function as an argument to a generic quickso...

best approach to extend a class funcionality in java?

for short, this could be paraphrased like "inheritance versus function library" for example, I'd like to add a method to the javax.servlet.http.HttpServletRequest that gives me the whole body, a getBody() method that would read the body thru the getReader method, just to put an example. In other languages, like ruby or javascript, you ...

How do I write a jquery function that accepts a callback as a parameter

I Have the following function. function ChangeDasPanel(controllerPath, postParams) { $.post(controllerPath, postParams, function(returnValue) { $('#DasSpace').hide("slide", { direction: "right" }, 1000, function() { $('#DasSpace').contents().remove(); $('#DasSpace').append(returnValue).css("displ...