Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 132,679 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,201 people online right now. Registration is fast and FREE... Join Now!




Functions

 
Reply to this topicStart new topic

Functions

fyrestorm
post 10 Oct, 2002 - 02:26 PM
Post #1


D.I.C Lover

Group Icon
Joined: 4 Apr, 2002
Posts: 3,103



Thanked 2 times

Dream Kudos: 228
My Contributions


is there a way to call a function that you made when you click on a link?
User is offlineProfile CardPM

Go to the top of the page

Spider
post 10 Oct, 2002 - 03:28 PM
Post #2


Arachnid

****
Joined: 10 Jul, 2002
Posts: 769


My Contributions


would the javascript OnClick= function work?

thats all I can think of at the moment, I don't know of a simple way of doing this with php.

like this (I think)
CODE
<a href="http://www.blah.com" OnClick="<?php function() ?>">tada!</a>
User is offlineProfile CardPM

Go to the top of the page

The Neoracle
post 10 Oct, 2002 - 04:53 PM
Post #3


Check, check, 1, 2.

Group Icon
Joined: 30 Mar, 2001
Posts: 4,069



Thanked 1 times
My Contributions


Uh, in PHP? Are you kidding? Don't you not understand the way PHP works? Come on, your a better programmer than that. wink2.gif
User is offlineProfile CardPM

Go to the top of the page

fyrestorm
post 10 Oct, 2002 - 04:59 PM
Post #4


D.I.C Lover

Group Icon
Joined: 4 Apr, 2002
Posts: 3,103



Thanked 2 times

Dream Kudos: 228
My Contributions


i've never called a function from a link


but anyways, i figured another way to do what i needed to do...
User is offlineProfile CardPM

Go to the top of the page

The Neoracle
post 10 Oct, 2002 - 06:11 PM
Post #5


Check, check, 1, 2.

Group Icon
Joined: 30 Mar, 2001
Posts: 4,069



Thanked 1 times
My Contributions


Cause you can't in PHP. It's a server parsed language, not client side. You can't make PHP execute once it's been loaded cause it's no longer PHP, it's all HTML. Think courtney, think.
User is offlineProfile CardPM

Go to the top of the page

MathewS
post 11 Oct, 2002 - 03:15 AM
Post #6


D.I.C Regular

***
Joined: 14 May, 2002
Posts: 252



Thanked 1 times

Dream Kudos: 1
My Contributions


try this.
CODE

<---HTML--->
<a href='thispage.php?op=functiona'>

<---PHP--->

<?
function functiona() {
echo "functiona";
}

function functionb() {
echo "functionb";
}

switch($op) {

   case "functiona":
       functiona();
       break;

   case "functionb":
       functionb();
       break;

   default:
       break;
}
?>
User is offlineProfile CardPM

Go to the top of the page

supersloth
post 11 Oct, 2002 - 01:56 PM
Post #7


serial frotteur

Group Icon
Joined: 21 Mar, 2001
Posts: 19,521



Thanked 11 times

Dream Kudos: 2147483647

Expert In: being gentlemanly

My Contributions


edit: erp, just realised matthews posted pretty much the same thing. my bad, guess thats what i get for not reading. wink2.gif


CODE
<a href="index.php?a=2">


CODE
<?php if (a==1) { function() } elseif (a==2) { function2() } ?>


that should take care of what your trying to do (umm, i think)

and yes i know its not proper code. so sue me. tongue.gif
User is offlineProfile CardPM

Go to the top of the page

fyrestorm
post 12 Oct, 2002 - 06:51 AM
Post #8


D.I.C Lover

Group Icon
Joined: 4 Apr, 2002
Posts: 3,103



Thanked 2 times

Dream Kudos: 228
My Contributions


QUOTE(The Neoracle @ Oct 10 2002, 08:11 PM)
Cause you can't in PHP. It's a server parsed language, not client side. You can't make PHP execute once it's been loaded cause it's no longer PHP, it's all HTML. Think courtney, think.

see what happens when i go back to c++...i try to use it's functionality in a different language....thanks neo
User is offlineProfile CardPM

Go to the top of the page

Cookie Mobster
post 12 Oct, 2002 - 08:59 AM
Post #9


nooneenooneenooonee

Group Icon
Joined: 12 Oct, 2001
Posts: 4,723



Dream Kudos: 18
My Contributions


This code will call a funtion based on what you pass in as ?input but it is very insecure and should never be used on a website:
CODE

<?php
function sam(){
  echo "my name is sam";
}
$_GET['input']();
?>

if you pass sam as the value for input (?input=sam) it will run the sam function. wink2.gif
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 06:40AM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month