Jump to content

call another function in main page..


nrsh_ram

Recommended Posts

hello to all,

im new to php..

i need help...i learn a simple thing through php tutorials in net..

 

i have create a features_hod.php where have 4 tabs "profile,forms,report,search"...each tab have different functions:

 

eg:'profile->update,preview'  'forms->consultation,discussion,activity,attendance  'report->all,differ,active,withdraw,graduate'  'search->directly open the search form'

 

for example when i click the profile tab..it will show two function 'update n preview', for calling this functions...im using this coding

 

<?php

if (isset($_GET['pg']) && $_GET['pg'] != "") {

$pg = $_GET['pg'];

if (file_exists(''.$pg.'.php')) {

@include (''.$pg.'.php');

 

} elseif (!file_exists(''.$pg.'.php')) {

echo 'Page you are requesting doesn´t exist';

}

 

} else {

@include ('main/Features_HOD.php');

}

?>

 

by using this coding each tab can call own function, my problem is..how to i call the pages of this functions? i want if i click on 'update' it will show the update page, and wen i click on 'preview' it will show preview page...what is the coding? i really no idea...plz help

 

Link to comment
https://forums.phpfreaks.com/topic/134704-call-another-function-in-main-page/
Share on other sites

I'm not sure I follow your question. As you showed in your code, you can include another file's code with the include() function.

 

Are you asking how to call a function within that included file? If so, you call a function in exactly the same way as you normally would. When you include a file, it is exactly as if the code in that included file was present in the file doing the including. I.e. The following combination of foo.php and bar.php is identical to foobar.php:

 

foo.php:

<?php
include("bar.php");
bar();
?>

 

bar.php:

<?php
function bar(){
    echo 'foobar';
}
?>

 

foobar.php

<php
function bar(){
    echo 'foobar';
}
bar();
?>

 

If that wasn't what you were asking, then please rephrase your question.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.