Jump to content
Fórum Script Brasil
  • 0

$nothing


Henriko04

Question

Bom dia galera, espero que me ajudem, sou novo em PHP, estudando por auto-didática, mas gostaria de saber se há a existência dessa variável que retorna uma string vazia: $nothing, estou vendo esse conteúdo por DEITEl para Programadores WEB, e em um de seus exemplos, essa variável é encontrada, ao rodar o aplicativo web, se esta variável que retorna uma string vazia não deveria mostrar nem um valor, lógico, mas o compilador da erro que a variável não foi declarada. Agradeço a ajuda de todos sobre está dúvida, já pesquisei sobre essa variável, mas ainda não encontrei resposta. Obg...

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0
Em PHP não.

Este é o código postado no LIVRO - Deitel para programadores WEB

<?php print( '<?xml version = "1.0" encoding = "utf-8"?>' ) ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<!-- Fig. 19.4: operators.php -->

<!-- Using arithmetic operators. -->

<html xmlns = "http://www.w3.org/1999/xhtml">

<head>

<title>Using arithmetic operators</title>

</head>

<body>

<?php

$a = 5;

print( "The value of variable a is $a <br />" );

// define constant VALUE

define( "VALUE", 5 );

// add constant VALUE to variable $a

$a = $a + VALUE;

print( "Variable a after adding constant VALUE

is $a <br />" );

// multiply variable $a by 2

$a *= 2;

print( "Multiplying variable a by 2 yields $a <br />" );

// test if variable $a is less than 50

if ( $a < 50 )

print( "Variable a is less than 50 <br />" );

// add 40 to variable $a

$a += 40;

print( "Variable a after adding 40 is $a <br />" );

// test if variable $a is 50 or less

if ( $a < 51 )

print( "Variable a is still 50 or less<br />" );

// test if variable $a is between 50 and 100, inclusive

elseif ( $a < 101 )

print( "Variable a is now between 50 and 100,

inclusive<br />" );

else

print( "Variable a is now greater than 100 <br />" );

// print an uninitialized variable

print( "Using a variable before initializing:

$nothing <br />" ); // nothing evaluates to ""

// add constant VALUE to an uninitialized variable

$test = $num + VALUE; // num evaluates to 0

print( "An uninitialized variable plus constant

VALUE yields $test <br />" );

// add a string to an integer

$str = "3 dollars";

$a += $str;

print( "Adding a string to variable a yields $a <br />" );

?><!-- end PHP script -->

</body>

</html>

<!--

**************************************************************************

* © Copyright 1992-2008 by Deitel & Associates, Inc. and *

* Pearson Education, Inc. All Rights Reserved. *

* *

* DISCLAIMER: The authors and publisher of this book have used their *

* best efforts in preparing the book. These efforts include the *

* development, research, and testing of the theories and programs *

* to determine their effectiveness. The authors and publisher make *

* no warranty of any kind, expressed or implied, with regard to these *

* programs or to the documentation contained in these books. The authors *

* and publisher shall not be liable in any event for incidental or *

* consequential damages in connection with, or arising out of, the *

* furnishing, performance, or use of these programs. *

**************************************************************************

-->

Link to comment
Share on other sites

  • 0
Pelo contexto do livro, ele está dando um exemplo de uma variável chamada $nothing, e o que acontece se você tentar mostrar ela na tela se ela não existir.

The value of variable a is 5

Variable a after adding constant VALUE is 10

Multiplying variable a by 2 yields 20

Variable a is less than 50

Variable a after adding 40 is 60

Variable a is now between 50 and 100, inclusive

Notice: Undefined variable: nothing in C:\xampp\htdocs\Projeto03\teste01.php on line 49

Using a variable before initializing:

Notice: Undefined variable: num in C:\xampp\htdocs\Projeto03\teste01.php on line 52

An uninitialized variable plus constant VALUE yields 5

Adding a string to variable a yields 63

Link to comment
Share on other sites

  • 0
Pelo contexto do livro, ele está dando um exemplo de uma variável chamada $nothing, e o que acontece se você tentar mostrar ela na tela se ela não existir.

Agora caro amigo, lógico, se dentro do código eu declarar a varável $nothing, esse erro desaparecer, mais segundo o LIVRO a variável $nothing é avaliada com uma string vazia, que são variável não-inicializadas, acho que ve me entender

The value of variable a is 5

Variable a after adding constant VALUE is 10

Multiplying variable a by 2 yields 20

Variable a is less than 50

Variable a after adding 40 is 60

Variable a is now between 50 and 100, inclusive

Notice: Undefined variable: nothing in C:\xampp\htdocs\Projeto03\teste01.php on line 49

Using a variable before initializing:

Notice: Undefined variable: num in C:\xampp\htdocs\Projeto03\teste01.php on line 52

An uninitialized variable plus constant VALUE yields 5

Adding a string to variable a yields 63

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...