我刚刚开始使用PHP进行OOP编程,并且我已经创建了一个cookie类.
通过这样做,我有几个问题没有答案
我的班级是否正确?
如何在我的页面中正确使用它?(我想我想看看访问者之前访问过我的网站的次数并为用户输出结果)
我在登录并使用此代码后已对其进行了测试:
$cookie = new Cookie();
$cookie->store();
print_r($_COOKIE);
Run Code Online (Sandbox Code Playgroud)
(我有一个结果被抛回但我不知道它是否是好结果)Bellow你可以找到我的Cookie类.
<?php
class Cookie {
/* cookie $id */
private $id = false;
/* cookie life $time */
private $time = false;
/* cookie $domain */
private $domain = false;
/* cookie $path */
private $path = false;
/* cookie $secure (true is https only) */
private $secure = false;
public function __construct ($id, $time = 3600, $path = false, $domain = false, $secure = false) {
$this->id = …Run Code Online (Sandbox Code Playgroud) 我有一个项目,当你在本地工作时,URL工作正常
本地主机:9000/
URL会变成
至于一些改变,我现在就去了
http:// localhost:9000 /#!/(带有感叹号)
此外,其他网址变得奇怪.如果我尝试点击一个链接,例如,转到仪表板.它不需要我.相反,它使URL像
/#!/#%2Fdashboard
之后没有任何反应.我做错了什么,我怎么可能解决这个问题?我不能显示任何代码,因为我不知道我哪里出错了.我按照以下教程,然后发生了问题.也许错误就在那里?
我添加了我的.config来设置路由.
.config(function ($routeProvider, $httpProvider) {
$routeProvider
.when('/', {
templateUrl: 'views/main.html',
controller: 'MainCtrl',
controllerAs: 'vm',
activetab: 'main'
})
.when('/about', {
templateUrl: 'views/about.html',
controller: 'AboutCtrl',
controllerAs: 'vm',
activetab: 'about'
})
.when('/faq', {
templateUrl: 'views/faq.html',
controller: 'FaqCtrl',
controllerAs: 'vm',
activetab: 'faq'
})
.when('/dashboard', {
templateUrl: 'views/dashboard.html',
controller: 'DashboardCtrl',
controllerAs: 'vm',
activetab: 'dashboard'
})
.when('/logout', {
templateUrl: 'views/main.html',
controller: 'LogoutCtrl',
controllerAs: 'vm'
})
.otherwise({
redirectTo: '/'
});
$httpProvider.interceptors.push(['$q', '$window', '$localStorage', …Run Code Online (Sandbox Code Playgroud) 我的标签栏控制器中有一个视图,我想在其中显示一个按钮。我根据条件以编程方式创建此按钮,因此我使用以下代码,但未显示任何内容:
override func viewDidLoad() {
super.viewDidLoad()
if !Settings.getIsConnected() {
notConnected()
}
}
func notConnected() {
let connectBtn = UIButton(frame: CGRect(x: self.view.center.x, y: self.view.center.y, width: 200, height: 45))
connectBtn.setTitle("Connect", forState: .Normal)
connectBtn.addTarget(self, action:#selector(self.pressedConnect(_:)), forControlEvents: .TouchUpInside)
self.view.addSubview(connectBtn)
print("Button created")
}
func pressedConnect(sender: UIButton!) {
}
Run Code Online (Sandbox Code Playgroud)
我对做错事一无所知。有人有建议吗?因为它确实打印出“创建的按钮”,所以它肯定在noConnected()方法内运行代码。
你好,我有一个用Java绘制明星的课程,它有点像魅力.在此之后我扩展了Star类以创建另一个具有扩展可能性的星(在这种情况下颜色必须不同)
由于某些原因,当我调用类并使用构造函数给出参数时,我的面板中只有子类颜色似乎有效.
这是我的代码
public class Star {
protected int radius;
protected int xmiddelpunt;
protected int ymiddelpunt;
protected static Color color;
public Star(int radius, int x, int y, Color color) {
xmiddelpunt = x;
ymiddelpunt = y;
this.radius = radius;
this.color = color;
}
}
Run Code Online (Sandbox Code Playgroud)
和扩展的类
public class StarRed extends Star {
protected int x, y;
protected static Color color;
Random red = new Random();
public StarRed(int radius, int x, int y, Color color) {
super(radius, x, y, color);
this.radius = …Run Code Online (Sandbox Code Playgroud) 我尝试在laravel已经存在的会话中添加一个键和一个值,这很好,但关键不是我传递了Session函数
public function selectCar() {
$reservation['car'] = Input::get('id');
if (Session::has('car')) {
Session::forget('car');
}
if (Input::has('id'))
{
Session::push('reserveringen', $reservation['car']);
}
$data = Session::all();
return Redirect::back()->with('success', 'Auto gekozen')->with('sessie', $data);
}
Run Code Online (Sandbox Code Playgroud)
输出是
[reserveringen] => Array
(
[pickupdate] => 'date'
[pickuptime] => 'time'
[returndate] => 'date'
[returntime] => 'time'
[0] => 37
)
Run Code Online (Sandbox Code Playgroud)
但它显示0而不是'汽车'接下来的事情是,如果会话已经包含汽车我希望旧的删除并被新的替换.有人能给我一个如何实现这个目标的例子吗?
我尝试使用bootstrap与bower和grunt为我的Laravel项目创建一个好的CSS,一切正常,直到我尝试使用命令
grunt less
Run Code Online (Sandbox Code Playgroud)
在我的终端,它说
NameError:变量@ font-family-base在第28行第16列的bower_components/bootstrap/less/scaffolding.less中未定义
当然,这会发生在bootstrap目录中的所有变量中.我之前读过有这个问题的人,之前有UTF8结构和BOM,但是在我的编辑器(PHPSTORM)中,当我右键单击bootstrap文件夹并点击删除BOM时它没有帮助.
我还能做些什么来完成这项工作?
ps我已经使用本教程来创建结构
byte-order-mark phpstorm twitter-bootstrap gruntjs twitter-bootstrap-3
您好我很好奇如何解决这个问题:我在Java中使用fillArc,drawArc方法创建了一个pacman,我现在屏幕上有一个pacman人,无论方向如何,总是向右看..我的问题是..有没有办法逐个改变对象或在Java中水平翻转它?
我试图使用AffineTransform,但我没有得到我想要的文档...我应该如何使用switch语句实现这一点?我试着做以下事情但是我被困在这个部分,因为我不知道如何继续.
DrawPacMan pacman = new DrawPacMan();
DrawPacMan ghost1 = new DrawPacMan();
DrawPacMan ghost2 = new DrawPacMan();
AffineTransform pac = new AffineTransform();
public void setPacManView(int waarde) {
// set the view of pacman
switch (waarde) {
case 0 :
// here one view of pacman
break;
case 1 :
// here one view of pacman
break;
case 2 :
// here one view of pacman
break;
case 3 :
// here one view of pacman
break;
}
}
public void …Run Code Online (Sandbox Code Playgroud) 我正在练习一些PHP OOP,因此我正在创建一个类来创建一个简单的导航菜单(将来带有扩展名),现在我已经建立了该类,该类的效果有点..具有1个菜单项。.我不知道如何在我的班级中使用数组来像
<?php
$menu = new Navigation("Test", "mainmenu");
$menu->setMenuItem("home", "test");
echo $menu->display();
?>
Run Code Online (Sandbox Code Playgroud)
如您所见,我应该能够为每个菜单项设置setMenuItem(); 方法。但是由于它目前不使用数组,所以我只能得到第一个值
该类本身如下:
<?php
class Navigation implements navigationInterface {
public $menu = null;
public $name = null;
public $klasse = null;
public function __construct($name, $klasse) {
$this->name = $name;
$this->klasse = $klasse;
}
public function getName() {
return $this->name;
}
public function getClass() {
return $this->klasse;
}
public function setMenuItem($items) {
$this->menuItem = $items;
}
public function getMenuItem() {
return $this->menuItem;
}
public function display() {
$menu …Run Code Online (Sandbox Code Playgroud) 您好我有以下代码,以查看JComboBox中的项是否是类(Persoon)的实例.
public class ItemChangeListener implements ItemListener {
Persoon selectedPerson;
RekeningApp app;
PersoonView view;
public ItemChangeListener(PersoonView view) {
this.view = view;
}
public void itemStateChanged(ItemEvent event) {
if (event.getStateChange() == ItemEvent.SELECTED) {
Object item = event.getItem();
System.out.println("Itemchangelistener " + item);
// do something with object
if(item instanceof Persoon) {
System.out.println("Instance");
this.selectedPerson = (Persoon) item;
view.setOverzicht(this.selectedPerson);
} else {
this.selectedPerson = null;
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
item的输出是persoon.name变量的值.所以JComboBox中的项目实际上是字符串.
这就是JComboBox列表的设置方式.
personenList.addItem(persoon.getNaam());
我的问题是..如何检查这个Persoon对象是否存在并且与JComboBox中的相同?
您好我在数据库中有一个STATUS字段作为枚举类型.
但是我如何为此创建setter?as String,INT或"Java Enum"
这样的事情
public enum getStatus() {
return Status;
}
public void setStatus(enum Status) {
this.Status = Status;
}
Run Code Online (Sandbox Code Playgroud)