Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Call a function from Included file?
- // MyFunc.php
- <?php
- function DoStuff()
- {
- $var = 'something';
- return $var;
- }
- ?>
- // index.php
- <html>
- <head></head>
- <body>
- Hi, I am currently doing <?php include "MyFunc.php"; echo DoStuff(); ?>, pretty cool, right?
- </body>
- </html>
- //splashgen.php
- <?php
- $refid = $_GET['ref'];
- $output = 'Company';
- function GetSponsor()
- {
- if($refid!='')
- {
- $dbhost = "localhost";
- $dbuser = "myuser";
- $dbpass = "mypass";
- $dbname = "mydb";
- $sqlselect = "SELECT * FROM egbusiness_members WHERE loginid='$refid';";
- $con = mysql_connect($dbhost,$dbuser,$dbpass) or die('Unable to connect to Database Server!');
- mysql_select_db($dbname) or die('Could Not Select Database!');
- $refid = stripslashes($refid);
- $refid = mysql_real_escape_string($refid);
- $result = mysql_query($sqlselect);
- while ($row = mysql_fetch_array($result))
- {
- $output = $row['name_f']." ".$row['name_l']." (".$refid.")";
- }
- mysql_close($con);
- }
- return $output;
- }
- ?>
- /////////
- // index.php
- ...
- <font style="font-size:19px" color="#0093C4" face="Calibri"><b>
- This page was brought to you by: <?php $_GET['ref']; include "../splashgen.php"; echo GetSponsor(); ?>
- </b></font></div>
- ...
- <body>
- Hi, I am currently doing <?php include "MyFunc.php"; echo DoStuff(); ?>, pretty cool, right?
- </body>
- echo DoStuff();
- <body>
- Hi, I am currently doing <?php include "MyFunc.php"; echo DoStuff; ?>,
- pretty cool, right?
- </body>
- <body>
- Hi, I am currently doing <?php include "MyFunc.php";
- echo DoStuff(); ?>, pretty cool, right?
- </body>
- function GetSponsor() {
- function GetSponsor($refid) {
- <font style="font-size:19px" color="#0093C4" face="Calibri"><b>
- This page was brought to you by: <?php $_GET['ref'];
- include "../splashgen.php"; echo GetSponsor(); ?>
- </b></font>
- <font style="font-size:19px" color="#0093C4" face="Calibri"><b>
- This page was brought to you by:
- <?php
- include "../splashgen.php";
- $refid = $_GET['ref'];
- echo GetSponsor($refid); ?>
- </b></font>
- Function DoStuff($var)
- {
- if($var != '')
- {
- return 'I am currently '.$var;
- }
- }
- ...
- echo DoStuff('posting on Stack Overflow');
Add Comment
Please, Sign In to add comment