Welcome, Guest. Please login or register.
Did you miss your activation email?
02/09/12, 03:14
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  Server side Scripting and Database Support
| |-+  PHP, Perl, ASP, JSP, CFM (Moderators: Flash-db, Musicman, vesa kortelainen, Ronald Wernecke, Jorge Solis, nothingGrinder)
| | |-+  increase variable in Heredoc
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: increase variable in Heredoc  (Read 1372 times)
till
Seasoned Programmer
***
Posts: 200



View Profile WWW Email
« on: 03/16/10, 02:53 »

Hi!

how can i increase a variable in a php Heredoc?

i want a user to change text-size.

in site.css.php:

h1 {
font-size : $text_size + 1$px;
}


Code:
<?php
header
("Content-type: text/css");

require_once(
'../CMS/config.inc.php');

$text_size $_SESSION['text_size'];
$px 'px';

   
$str = <<<DEMO

h1 { 
font-size : $text_size + 1$px; 
}

DEMO;
 
   echo 
$str;
?>



and on index.php:
Code:
<?php
 
if(session_is_registered('text_size') ){
   
          if(isset(
$_GET[size_plus])){
  
     $_SESSION['text_size'] = $_SESSION['text_size'] + 2;
  
  
  }
  
          if(isset(
$_GET[size_minus])){
  
     $_SESSION['text_size'] = $_SESSION['text_size'] - 2;
  
  
  }
   
   
   }else{
   
   
$_SESSION['text_size'] = '10';
   
   }


echo 
'<a class="normlink" href=" $_SERVER['PHP_SELF'] ?size_plus">plus</a> | <a class="normlink" href=" $_SERVER['PHP_SELF'] ?size_minus">minus</a>';
?>


i cant get this working in site.css.php:

h1 {
font-size : $text_size + 1$px;
}



when i look at the html-sorce in my browser it prints:
....
font-size : 10 + 1px;   // (exactly this)
....

i also tried it with brackets and points and quotes without success.

it doesnt encrease the the variable

thanks for helping.
till.




Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6162


View Profile WWW Email
« Reply #1 on: 03/16/10, 03:29 »

your size value is stored as string - so you have to convert it to a integer value.

Use
Code:
$textsize=intval($_SESSION['text_size'])+1;
and
Code:
echo "h1{\nfont-size : ".$textsize." px\n}";
Logged

happy flashing
Cool
Ronald
Pages: [1] Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
anything