Questions tagged [unset]

Removing the value associated with a variable or property from the current environment.

Common usages:

  • Destroying a variable or member of an array in PHP.
  • Removing the value bound to a property in Apache Ant.
  • Removing a variable from the environment of a shell script.
595 questions
6
votes
1 answer

Why css "all: unset" works weirdly in Safari browser for MacOS?

So basically I made this situation, the parent has the css all: unset. Then I notice when I use Safari(Version 12.1.1 (14607.2.6.1.1)) all the children of it color only can be effected by * block, not even inline or !important. But only color…
Hao Wu
  • 17,573
  • 6
  • 28
  • 60
6
votes
3 answers

Reset PHP array index to start from 0 after unset operation

I have an array $cars = array("Volvo", "BMW", "Toyota", "Mercedes"); I wanted to remove first element "Volvo" and i use this unset($cars[0]); Now i have an array like this: Array ( [1] Bmw [2] Toyota [3] Mercedes ) But i want to…
user9819807
6
votes
1 answer

Remove cached password for Git on Windows

I have recently updated my Github password at work (corporate Github account). I had configured Git on one of my VM which is Windows 10. Not whenever I do git pull or git push it throws error message: remote: Invalid username and password fatal:…
ID 4JOB
  • 61
  • 1
  • 1
  • 2
6
votes
5 answers

do we need to "unset" variables in TCL?

Is it a requirement of good TCL code? What would happen if we don't use the "unset" keyword in a script? Any ill-effects I should know about? I'm inheriting some legacy code and the errors that come about due to "unset"-ing non-existent variables…
chronodekar
  • 2,616
  • 6
  • 31
  • 36
5
votes
2 answers

How to unset global variables.

I have an id of a project and an id of a client that are sessions in php that are passed in JSON format. These are stored in global variables id_p and id_c so I can do multiple inserts and updates selects etc. with those ids. When the user selects…
Samuel Lopez
  • 2,360
  • 6
  • 29
  • 39
5
votes
2 answers

GIT & Ruby: How can I unset the GIT_DIR variable from inside a ruby script?

I've written a very simple 'deploy' script running as my post-update hook inside my bare git repo. The variables are as follows live domain = ~/mydomain.com staging domain = ~/stage.mydomain.com git repo location =…
Jannis
  • 17,025
  • 18
  • 62
  • 75
5
votes
5 answers

How can I unset a variable in C to allow usage of the same name with different datatype later on?

I want to use the same variable name with a different datatype in C program without casting. I really wanna do that don't ask why. So how can I do that ? And how can I handle the error if this variable doesn't exist while doing prophylactic…
AssemblerGuy
  • 603
  • 2
  • 6
  • 12
5
votes
2 answers

Why does "isset($a[0]) and unset($a[0]);" cause syntax error?

My Code: $a = []; isset($a[0]) and unset($a[0]); it shows "syntax error, unexpected 'unset' (T_UNSET)" but $a = []; isset($a[0]) and exit(); it works! Both of exit() and unset() are returning no value. Why does one work but not the other?
yrssoft
  • 79
  • 7
5
votes
4 answers

How to unset global variable in php?

I know very basic of php and web programming. Here is my php code. I have seen couple of similar questions. They unset global variable with unset function. I want every time user open the url, a username and password prompt and after entering…
Bernard
  • 4,240
  • 18
  • 55
  • 88
5
votes
1 answer

How does PHP's 'unset' construct work internally?

Preface: I do know how 'unset' works in the userland, but I would like to find out how it works internally. When unset is called on zval structure, it decreases the reference counter (refcount__gc). When refcount__gc reaches 0, the variable is no…
itsmeee
  • 1,627
  • 11
  • 12
5
votes
2 answers

PHP foreeach deleting array element

Today while working on text analysing tool for blogs, I found PHP behavior very strange for me and just couldn't wrap my head around it. While normalizing text, I was trying to remove words below minimum length, so I wrote this in my normalization…
user2742648
5
votes
3 answers

Remove items from an array where they match a certain criteria in PHP

I have an array of products and i need to remove all of them which have a reference to webinar The PHP version I am using is 5.2.9 $category->products example: [6] => stdClass Object ( [pageName] =>…
Andy
  • 2,991
  • 9
  • 43
  • 62
5
votes
6 answers

Destroy defined key with define function

How I can destroy an const? I tried unset( KEY ), but not work.
Mark Neto
  • 145
  • 4
  • 10
4
votes
2 answers

unset() static variable doesn't work?

See this code: http://codepad.org/s8XnQJPN function getvalues($delete = false) { static $x; if($delete) { echo "array before deleting:\n"; print_r($x); unset($x); } else { for($a=0;$a<3;$a++) { …
dukevin
  • 22,384
  • 36
  • 82
  • 111
4
votes
9 answers

Smarty: unset an array index in template

I would like to do {unset($array['index'])} into a Smarty 3 template. Is such a syntax (or similar) supported ? After Googling and doc reading I can't find something satisfying. Maybe I should ask for a feature request to Smarty dev team ?…
Maxime Pacary
  • 22,336
  • 11
  • 85
  • 113