Questions tagged [language-construct]

A language construct is a syntactically allowable part of a program that may be formed from one or more lexical tokens in accordance with the rules of a programming language.

In simpler terms, it is the syntax/way a programming language is written. However we do not recommend using this tag in this general semantic meaning as the general keyword syntax would fit it better.

55 questions
3
votes
7 answers

What does this syntax ( page = $page ? $page : 'default' ) in PHP mean?

I'm new to PHP. I came across this syntax in WordPress. What does the last line of that code do? $page = $_SERVER['REQUEST_URI']; $page = str_replace("/","",$page); $page = str_replace(".php","",$page); $page = $page ? $page : 'default'
2
votes
3 answers

What are the basic language constructs in java?

I've been asked to "Identify all language constructs in Java. Your list should start with classes: The body of class declarations" I was under the impression that a 'language construct' was any allowable command in a language, but this is clearly…
ABCooper
  • 21
  • 1
  • 1
  • 3
2
votes
5 answers

Calling PHP language constructs using a string

I wanna buffer some content. The way how the content is fetched depends, that's why I added a type parameter to my buffer function to define whether to include or to echo the source. PHP
Ben
  • 43
  • 2
  • 6
2
votes
2 answers

Does PHP have a facility to reduce the duplication of parameter declaration and initialization in the class and the constructor?

Consider writing the class below: class SomeClass { /** @var array */ private $files; /** @var string */ private $productName; /** @var bool */ private $singlePage; /** @var bool */ private $signatureRequested; …
Dennis
  • 7,907
  • 11
  • 65
  • 115
2
votes
2 answers

What does "array_expression" mean in php?

http://php.net/manual/en/control-structures.foreach.php Trying to better understand the foreach loop. In the documentation above it states "The first form loops over the array given by array_expression." What in the world is an array_expression?
Kohler Fryer
  • 764
  • 2
  • 8
  • 17
2
votes
1 answer

C# equivalent of C++ std::vector.end()

I was trying to rewrite some C++ code I found on the internet in C# for my hexagon sphere project, but I ran into the following code: if((((*ti)->m_hexA) != tileNdx) && (find(nbrs. begin(), nbrs.end(), ((*ti)->m_hexA)) == nbrs.end())) { …
Jax
  • 402
  • 7
  • 24
1
vote
0 answers

What is the purpose of this case label?

Inside boost/asio/coroutine.hpp there is case statement inside the definition of the macro yield which seems to be inaccessible: switch (_coro_value ? 0 : 1) \ for (;;) \ case -1: if (_coro_value) \ goto terminate_coroutine; \ …
Oliv
  • 17,610
  • 1
  • 29
  • 72
1
vote
1 answer

Is the Scala `match` construct syntactic sugar? If so, how does is work?

In trait Expr case class Number(n: Int) extends Expr case class Sum(e1: Expr, e2: Expr) extends Expr object CaseExample { def eval(e: Expr): Int = e match { case Number(n) => n case Sum(e1, e2) => eval(e1) + eval(e2) } def main(args:…
Make42
  • 12,236
  • 24
  • 79
  • 155
1
vote
2 answers

PHP Declarator In If-Statement Scope

This is pretty basic. Let's say you define a variable in an if statement if($stmt = $db->prepare($sql)) { // do stuff } Can I access $stmt below the if statement? Or does $stmt need to be defined above the if?
Kellen Stuart
  • 7,775
  • 7
  • 59
  • 82
1
vote
1 answer

Can I use variable functions with language constructs?

This question here kinda address the issue. In my case I would like to call a function like empty() or is_int(). For example:
Francisco Luz
  • 2,775
  • 2
  • 25
  • 35
1
vote
2 answers

var_dump() returning zero arry. unable to upload file PHP

upload.php The var_dump() function is returning zero array. What am i doing wrong here ?
Eskinder
  • 1,369
  • 1
  • 14
  • 24
1
vote
3 answers

if statement on one line if poss

I am printing an image using an ID which is generated. however i wanted to do a check to see if this image exists and if it doesnt print no-image.jpg instead...
Andy
  • 2,991
  • 9
  • 43
  • 62
1
vote
2 answers

Speedy attribute lookup in dynamically typed language?

I'm currently developing a dynamically typed language. One of the main problems I'm facing during development is how to do fast runtime symbol lookups. For general, free global and local symbols I simply index them and let each scope (global or…
1
vote
2 answers

increment a variable based on loop count

I have a PHP function where an undefined number of images in a directory are being output to the browser. The images are being read in to an object. The issue I'm having is how the images are presented. I want to put them in a table, four …
rwhite
  • 430
  • 2
  • 11
0
votes
2 answers

Which aspects of the JAVA conditional operator construct are described formally, and which are described informally

This question on my courswork that I could not understand. Q. The JAVA Language Specification (3rd Edn.) is available for browsing or downloading at java.sun.com/docs/books/jls/. Locate the section of it that describes the so-called conditional…
Mujtaba Alboori
  • 395
  • 1
  • 7
  • 20