Click here to Skip to main content
15,884,472 members
Home / Discussions / Linux, Apache, MySQL, PHP
   

Linux, Apache, MySQL, PHP

 
GeneralRe: More of a poll than a question... Pin
jschell15-Apr-11 8:58
jschell15-Apr-11 8:58 
Generaladd and show events on a calender in php/msql problem Pin
tryingmybest894-Apr-11 12:36
tryingmybest894-Apr-11 12:36 
GeneralRe: add and show events on a calender in php/msql problem Pin
Graham Breach5-Apr-11 0:16
Graham Breach5-Apr-11 0:16 
GeneralRe: add and show events on a calender in php/msql problem Pin
tryingmybest896-Apr-11 12:31
tryingmybest896-Apr-11 12:31 
GeneralRe: add and show events on a calender in php/msql problem Pin
Mutinda Boniface15-Apr-11 3:53
Mutinda Boniface15-Apr-11 3:53 
QuestionHow to know if a variable has been initiated or not [modified] Pin
Joan M30-Mar-11 7:56
professionalJoan M30-Mar-11 7:56 
AnswerRe: How to know if a variable has been initiated or not Pin
nickmaroulis30-Mar-11 13:35
nickmaroulis30-Mar-11 13:35 
GeneralRe: How to know if a variable has been initiated or not Pin
Joan M30-Mar-11 20:25
professionalJoan M30-Mar-11 20:25 
Hello Nick,

QUESTION PART:

This is something I've not understood properly:

if there is not a define, dim, type specification at the moment of declaring a variable, how one know where it has been declared?

Moreover if a web is not a structured setting of pages (I mean that one can access any page of the web without any specific order thanks to the search engines).

At the beginning of each file of the site I've got something like:

<?php
  include($_SERVER['DOCUMENT_ROOT'].'/file_that_must_be_included.php');
  $MyLangVar = $GLOBALS['MyLangVar'];  
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<h
<html>
  <head>


Then, inside the "file_that_must_be_included.php" I've done this:

<?php	
  include($_SERVER['DOCUMENT_ROOT'].'/another_global_file.php');

  if (!isset($MyLangVar))
  {
    $MyLangVar = "English";
  }
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  //defining styles + favicon...


Here it is where I'm trying to check if the variable has been initialized or not, and if it has not been initialized then I'm setting it to the default language.

CONCLUSIONS / IDEAS:
After writing the previous lines, I've thought:

* If declaring a variable inside a "if" clause makes it local, then having that "if (!isset..." it has no sense until the gloabal variable has been declared because just after leaving the if clause the var will be "destroyed".

* I guess I should change the line order in the main files: putting the "$MyLangVar = $GLOBALS['MyLangVar'];" line at the beginning, just before the "include($_SERVER['DOCUMENT_ROOT'].'/file_that_must_be_included.php');". In that way I've declared the $MyLangVar, it will become global for all the file (I guess, please confirm that) and therefore I'll only initialize it once (inside the sub_file "/file_that_must_be_included.php".

* I've tried that but in the 404.php file I can see a message telling me: Undefined index MyLangVar'...

Lost again... Sigh | :sigh:

Can you do something with all this data?

Thank you in advance! Thumbs Up | :thumbsup:
[www.tamelectromecanica.com] Robots, CNC and PLC machines for grinding and polishing.

GeneralRe: How to know if a variable has been initiated or not Pin
nickmaroulis30-Mar-11 21:03
nickmaroulis30-Mar-11 21:03 
GeneralRe: How to know if a variable has been initiated or not Pin
nickmaroulis30-Mar-11 21:18
nickmaroulis30-Mar-11 21:18 
GeneralRe: How to know if a variable has been initiated or not Pin
Joan M30-Mar-11 21:41
professionalJoan M30-Mar-11 21:41 
GeneralRe: How to know if a variable has been initiated or not Pin
User 171649230-Mar-11 22:28
professionalUser 171649230-Mar-11 22:28 
GeneralRe: How to know if a variable has been initiated or not Pin
Joan M30-Mar-11 22:51
professionalJoan M30-Mar-11 22:51 
QuestionProblem with pointers / permissions? Pin
whatsa25-Mar-11 10:15
whatsa25-Mar-11 10:15 
AnswerRe: Problem with pointers / permissions? Pin
cjoki25-Mar-11 13:31
cjoki25-Mar-11 13:31 
AnswerRe: Problem with pointers / permissions? Pin
effayqueue25-Mar-11 23:50
effayqueue25-Mar-11 23:50 
AnswerRe: Problem with pointers / permissions? Pin
nickmaroulis30-Mar-11 13:38
nickmaroulis30-Mar-11 13:38 
Questionhow to bypass web filter Pin
yftah198923-Mar-11 7:12
yftah198923-Mar-11 7:12 
AnswerCross Post: Please Ingore Pin
Keith Barrow23-Mar-11 8:48
professionalKeith Barrow23-Mar-11 8:48 
GeneralRe: Cross Post: Please Ingore Pin
Pete O'Hanlon23-Mar-11 9:21
mvePete O'Hanlon23-Mar-11 9:21 
GeneralRe: Cross Post: Please Ingore Pin
Keith Barrow23-Mar-11 9:44
professionalKeith Barrow23-Mar-11 9:44 
Questionsend data Pin
Elham M23-Mar-11 3:19
Elham M23-Mar-11 3:19 
AnswerRe: send data Pin
cjoki23-Mar-11 4:32
cjoki23-Mar-11 4:32 
GeneralRe: send data Pin
Elham M24-Mar-11 3:14
Elham M24-Mar-11 3:14 
GeneralRe: send data Pin
cjoki24-Mar-11 4:55
cjoki24-Mar-11 4:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.