Jump to content

[Resolvido] Conversão de String para Int


AnaSilva
 Share

Recommended Posts

Boas,

preciso de ajuda tentei varias formas de converter um valor mas nao estou a conseguir

tentei por tipo $var=(int)$var2; nem isso deu dá sempre 0 alguem pode-me ajudar? ou se existe outra forma de conseguir o tamanho do ecrã

o cod em baixo também nao dá =( será que tem algum erro ?

<?php
echo $altura = '<script type="text/javascript">  
  document.write(window.screen.height);
</script>';
echo '|||'.gettype($altura).'|||';
settype($altura, "integer");
if(is_numeric( $altura))
{ echo '-valor numerico:'.$altura;}
else
{ echo '-valor n é numerico';}

?>
Edited by AnaSilva
Link to comment
Share on other sites

Question: How do I get the screen size on the client machine?

Answer: To determine the screen size on the client machine, use the propertiesscreen.width and screen.height supported in all major browsers.

If you need a reduced value (subtracting the screen portion occupied by toolbars etc.), usescreen.availWidth and screen.availHeight.

Historical note: For Netscape Navigator 3 (with Java enabled), you could use a Java call to get the screen width and height (see the example below).

The following code sets the variables screenW and screenH to the actual width and height of the screen, and outputs the width and height values. If the user has an old browser, thenscreenW and screenH are set to 640 and 480, respectively.

var screenW = 640, screenH = 480;
if (parseInt(navigator.appVersion)>3) {
screenW = screen.width;
screenH = screen.height;
}
else if (navigator.appName == "Netscape"
   && parseInt(navigator.appVersion)==3
   && navigator.javaEnabled()
  )
{
var jToolkit = java.awt.Toolkit.getDefaultToolkit();
var jScreenSize = jToolkit.getScreenSize();
screenW = jScreenSize.width;
screenH = jScreenSize.height;
}
document.write(
"Screen width = "+screenW+"<br>"
+"Screen height = "+screenH
)
In your browser, this code produces the following output:
Screen width = 1366
Screen height = 768
  • Vote 1
Link to comment
Share on other sites

o que eu queria fazer era saber as dimensões do ecra, para isso preciso de javascript.... e depois preciso de fazer calculos com o valor que obtive... mas ja fiz de outra maneira.. enviei para o url a informação e depois converti para inteiro.. Wiki do ajax tbm nao consegui ^-^mas ja consegui resolver o prob mas brigada por me ajudarem 😄

echo "<script type='text/javascript'>  window.location='table.php?resolucao='+screen.height+'X'+screen.width;</script>";
$resol= explode("X", $_GET['resolucao']);
$ResolucaoLeft=($resol[1]/($linha+1));;//Tamanho Linha
 $ResolucaoTop=(($resol[0]-(200*0.5))/$Coluna)*0.8;// tamanho Coluna
Edited by AnaSilva
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. 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.