Join the Stack Overflow Community
Stack Overflow is a community of 6.3 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I've created code in php which is below

<?php

$text = $_POST["text"];
$name = $_POST["name"];

$Voice = new COM("SAPI.SpVoice");   

$FileStream = new COM("SAPI.SpFileStream"); 

$FileStream->Open("C:\\xampp\\htdocs\\1\\"$name"", 3, false); 
$Voice->AllowAudioOutputFormatChangesOnNextSet = false; 

$Voice->AudioOutputStream = $FileStream; 

$Voice->Speak($text);
$FileStream->Close();

?>

But It gives error syntax error, unexpected '$name' (T_VARIABLE) how can it be solved?

share|improve this question
1  
try using .$name and remove "" after $name – Nabin Kunwar Dec 15 '13 at 4:37
    
^ Two too many. Should be $FileStream->Open("C:\\xampp\\htdocs\\1\\$name", 3, false); – Devon Dec 15 '13 at 4:39
    
Thank you friend resolve the error – user2778768 Dec 15 '13 at 4:40
up vote 2 down vote accepted

When using ", you can just write

"C:\\xampp\\htdocs\\1\\$name"

Alternatively:

"C:\\xampp\\htdocs\\1\\{$name}"

Otherwise:

"C:\\xampp\\htdocs\\1\\" . $name

share|improve this answer

This is wrong

$FileStream->Open("C:\\xampp\\htdocs\\1\\"$name"", 3, false); 

It should be

$FileStream->Open("C:\\xampp\\htdocs\\1\\".$name, 3, false); 
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.