Jump to content


Photo

PLEASE help!!!


  • Please log in to reply
9 replies to this topic

#1 zasnemo

zasnemo
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 28 August 2006 - 02:16 AM

how can i pass variables from an function to a include inside it?

<?php
// index.php
function a() {
    $a= 'apples';
    include('fuit.php');

}

?>

<?php
// fruit.php
    echo $a;
?>

THANKS!!

#2 Satria Ox41464b

Satria Ox41464b
  • Members
  • PipPip
  • Member
  • 18 posts

Posted 28 August 2006 - 02:19 AM

works perfect here...
what about a(); at the end of your index.php ?

#3 Corona4456

Corona4456
  • Members
  • PipPipPip
  • Advanced Member
  • 244 posts
  • LocationEl Paso, TX

Posted 28 August 2006 - 02:22 AM

you don't need to pass it anything... $a will be global in fruit.php so you can do it just as you are doing it in your code
What is the CoronaMatrix?

#4 ChaosXero

ChaosXero
  • Members
  • PipPipPip
  • Advanced Member
  • 80 posts

Posted 28 August 2006 - 02:24 AM

If that is an exact copy, you misspelled fruit.  That might be the error, cause otherwise that should work.


#5 zasnemo

zasnemo
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 28 August 2006 - 02:25 AM

oh shite, i must of done the example wrong then.

im trying to edit SMF, which contains a:

function template_main_above()
{
global $context;
print_r($context);

$context comes out fine.

and in that function i include:

include('a.php');

in that a.php I try to
print_r($context);

but it doesnt come out :-S

#6 zasnemo

zasnemo
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 28 August 2006 - 02:32 AM

I doubled checked and added:

$fruit = 'aaaaaaa';

in

function template_main_above() function


then in my include('a.php');

I echo $fruit; but no answer :-S

#7 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 28 August 2006 - 02:46 AM

<?php
$include="a.php";

function template_main_above($include)
{
global $context;
print_r($context);

$context comes out fine.
echo $include;
}

?>




Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#8 zasnemo

zasnemo
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 28 August 2006 - 03:01 AM

mmm, wheres the include? I dont want to echo...

<?php
function template_main_above()
{
global $context;
print_r($context); // $context comes out fine.

include('aaaa.php');
}

?>

<?php //aaaa.php

global $context;
print_r($context); // $context DOESNT come out fine.

?>

#9 zasnemo

zasnemo
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 28 August 2006 - 03:06 AM

but guys... to make it simpler, this doesnt even work:

<?php
function template_main_above()
{
$aaa = 'aaa';
echo $aaa; // comes out fine
include('aaaa.php');
}

?>

<?php //aaaa.php

echo $aaa; // doesnt come out fine

?>

:'( :'(

#10 zasnemo

zasnemo
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 28 August 2006 - 05:19 AM

Solved it, dont know how... whatever :P




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users