php


how to access the variable from another php file


I have an array in one php1 file which I want to access in another php2 file but if i use either include or require once am also getting the output of the php1 file. I want to access only the variables from php1 but not the output. Can anyone suggest how to do that. In php1 I have lot of menus and boxes which I don't want to include in php2 except the variables.
<?
session_start();
require_once('home.php');
if($_GET["reset"]==1)
{
session_destroy();
header('Location: index.php');
}
?>
if i use this am getting all the output from the home.php page. I want only the variables.
Convert the variables on the home page to be accessible via a function or better still, make them session variables
is there some way without using function or session to access the variables
As per your request. A simple skeleton to show you how it is done.
We pass the variable $myVar through the URL and use $_GET in the next page to use it. We use htmlspecialchars(); to clean user input.
We use the if (isset($_GET['myVar'])) so it doesn't throw Notice: Undefined index error.
pageOne.php
<?php
$myVar = "My variable one.";
echo "<a href='pageTwo.php?myVar=" . $myVar . "'>Page Two</a>"
?>
pageTwo.php
<?php
if (isset($_GET['myVar'])) {
$myVar = htmlspecialchars($_GET['myVar'], ENT_QUOTES);
// Now you can use $myVar.
}
?>

Related Links

php use variable name when call static property [duplicate]
Mysql seems to remove slashes from string
Disable submit button after form validation PHP
How to store data inside session array in given format?
Guzzle CacheSubscriber first response is empty
Python ENV file overwritten by PHP ENV
Passing JSON data from Controller to Model
Trying to learn to write a RegExp for PHP
Why the function doesnt work? [duplicate]
Is this code is a good PHP practice for treat results from my query?
jQuery code that has been written does not pass correct value based on clicking
Adding a row div after every four post in wordpress
How to get /insights/page_fans_country/ with PHP?
PHP Sort Order Proccess Codeiginiter
Getting the error “declaration of DateTimeValue::make() should be compatible with”
Retrieving and displaying data in Php from Mysql

Categories

HOME
orientdb
key
message-queue
risk-management
slider
iverilog
mirc
ontology
jint
fedora
angular-meteor
cisco
mutation-testing
siesta
lda
twitter-oauth
lapack
clish
bootstrap-switch
django-rq
word2vec
salt-cloud
significance
spam
angular2-highcharts
gitkraken
data-type-conversion
anova
el
coreldraw
backtracking
ava
exchange-server-2010
environment
jpa-2.1
strophe.js
matlab-app-designer
source-insight
instructions
xmlunit
polyml
db2-luw
autoencoder
dreamfactory
jfxtras
cups
textmate2
landscape
spinner
django-crispy-forms
strapi
stat
suds
opal-framework
coverage.py
nuclio
react-intl
music21
nusoap
lightning-workbench
subforms
line-intersection
palindrome
popen
nivo-slider
boost-compute
okio
nvda
between
adp
gnucash
highlighting
fdt
utf-16
gravatar
certificate-authority
wepay
android-mapview
fanotify
dnx50
hmisc
gql
ngcordova
swagger-maven-plugin
relational-model
tree-structure
fuseesb
gflags
innerhtml
fat32
symja
object-code
aho-corasick
squeezebox
two.js
reference-counting
boolean-algebra
gpu-programming
roxy-fileman
mod-perl
mute
postgres-xc
background-thread
audiotoolbox
clearinterval
pageheap
hardcode
algol68
quartz-core
will-paginate
ccl
reliability
cleartype
eventaggregator
ntruencrypt
isapi-redirect
code-camp
account-management

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile